Bug with IN since version 3.47.0
(1) By Guillaume Ayoub (yabz69) on 2024-11-19 21:37:19 [source]
Since SQLite 3.47.0, I have a problem with the IN operator for joined tables on columns with the UNIQUE constraint.
CREATE TABLE t1 (a int UNIQUE);
CREATE TABLE t2 (b int UNIQUE);
INSERT INTO t1 VALUES (1);
INSERT INTO t2 VALUES (1), (2);
SELECT t1.a, t2.b FROM t1, t2 WHERE (t1.a, t2.b) = (1, 1);
┌───┬───┐
│ a │ b │
├───┼───┤
│ 1 │ 1 │
└───┴───┘
SELECT t1.a, t2.b FROM t1, t2 WHERE (t1.a, t2.b) IN ((1, 1));
┌───┬───┐
│ a │ b │
├───┼───┤
│ 1 │ 1 │
└───┴───┘
SELECT t1.a, t2.b FROM t1, t2 WHERE (t1.a, t2.b) = (1, 2);
┌───┬───┐
│ a │ b │
├───┼───┤
│ 1 │ 2 │
└───┴───┘
SELECT t1.a, t2.b FROM t1, t2 WHERE (t1.a, t2.b) IN ((1, 2));
As you can see, the last request doesn’t return anything. The exact same SQL works correctly with 3.46.1, the last request gives (1, 2).
(2.1) By Richard Hipp (drh) on 2024-11-20 10:46:20 edited from 2.0 in reply to 1 [link] [source]
Bisects to this check-in: https://sqlite.org/src/info/c9a3498113074bbc
Confirmed that this is a bug in as much as PostgreSQL gives the same answer as 3.46.0.
(3) By Richard Hipp (drh) on 2024-11-20 15:06:49 in reply to 1 [link] [source]
Now fixed on trunk by check-in 19d1bede5654bcfa and on branch-3.47 by check-in 16d46e116086948a. Please try out one or the other of these fixes and verify that they resolve your original issue. Thanks for the bug report and for the simplified test case.
(4) By Guillaume Ayoub (yabz69) on 2024-11-20 15:28:39 in reply to 3 [link] [source]
It works perfectly. Thanks a lot for the quick fix, and for this wonderful library. ❤️