Skip to content
Snippets Groups Projects
Commit de53867d authored by Nikita Pettik's avatar Nikita Pettik
Browse files

sql: discard numeric conversion by unary plus

In SQLite unary plus behaves as implicit conversion to numeric type.
Consider following example:

CREATE TABLE t1 (id INT PRIMARY KEY, a TEXT, b BLOB);
INSERT INTO t1 VALUES (1, '99', '99');

SELECT * FROM t1 WHERE a = b; (*)
SELECT * FROM t1 WHERE +a = +b; (**)

Since BLOB and TEXT are incompatible, result of (*) would be empty set.
However, comparison in second query (**) would be of <NUMERIC> types,
and result set would consist of one tuple [1, '99', '99'].

Lets discard this conversion produced by unary plus, since it implicitly
affects result set of query and no one other DB support such behaviour.
Instead, simply use type of operand it is related to.
Note, that unary minus doesn't affect types in any way.
parent 7752cdfd
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment