You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
NOT binds tighter than IN and BETWEEN: WHERE NOT x IN (32) finds no rows #2768
NOT binds tighter than IN and BETWEEN, so NOT x IN (...) is read as (NOT x) IN (...). In SQL, NOT binds looser than the comparison operators, so it means NOT (x IN (...)). #386 fixed this for NOT a = b; IN and BETWEEN still have the old order. Seen in the sqllogictest run (test/random/expr/, for example CASE WHEN NOT 5 IN ( 43 + - 11 ) THEN ...), reproduced on develop (06211a0) and npm 4.20.1, compared with SQLite 3.43.2:
alasql('CREATE TABLE u (x)');alasql('INSERT INTO u VALUES (5), (0)');
Query
AlaSQL
SQLite
SELECT x FROM u WHERE NOT x IN (32)
no rows
5, 0
SELECT x FROM u WHERE NOT (x IN (32))
5, 0
5, 0
SELECT x FROM u WHERE NOT x BETWEEN 1 AND 3
0
5, 0
SELECT NOT 5 IN (32)
false
1
SELECT NOT 0 IN (1)
false
1
SELECT NOT 5 BETWEEN 1 AND 3
false
1
SELECT NOT -48 NOT BETWEEN -53 AND 29
false
1
SELECT NOT 5 = 3, NOT 5 > 3, NOT 5 LIKE 6, NOT 5 IS NULL
same as SQLite
Not breaking: the answer is wrong for every row, as it was for = before #386.
The same with a parenthesised left operand, the most common form in test/random/aggregates/ (WHERE NOT ( col2 ) IN ( + 5 ), WHERE NOT ( - col2 ) BETWEEN - col1 AND 84). t holds c0 = 1, 2, 3; develop06211a0, SQLite 3.43.2:
Activity
mathiasrw commentedon Oct 21, 2026
The same with a parenthesised left operand, the most common form in
test/random/aggregates/(WHERE NOT ( col2 ) IN ( + 5 ),WHERE NOT ( - col2 ) BETWEEN - col1 AND 84).tholdsc0= 1, 2, 3;develop06211a0, SQLite 3.43.2:SELECT c0 FROM t WHERE NOT (c0) IN (2)SELECT c0 FROM t WHERE NOT ( c0 ) BETWEEN 2 AND 3SELECT NOT (2) IN (5)SELECT NOT (2) <= 1mateuscmtropical commentedon Nov 11, 2026
Hi, I'd like to work on this one.
mateuscmtropical commentedon Nov 11, 2026
Hi, I've opened a PR for this: #3047
Process `NOT x IN (...)` and `NOT x BETWEEN ...` as `NOT (x IN ...)` to