cznic / ql

github.com/cznic/ql has moved to modernc.org/ql
https://godoc.org/modernc.org/ql
BSD 3-Clause "New" or "Revised" License
1.31k stars 75 forks source link

Confusing test case #163

Closed gernest closed 7 years ago

gernest commented 7 years ago

So, I revisited the testdata.ql file

this snippet

-- 1350 // https://github.com/cznic/ql/issues/155
BEGIN TRANSACTION;
    CREATE TABLE t (i int);
    INSERT INTO t VALUES (1);
    INSERT INTO t VALUES (2);
    INSERT INTO t VALUES (3);
COMMIT;
SELECT * FROM t WHERE EXISTS (SELECT * FROM t WHERE i == 4);
|"i"
[]

My understanding is. The query will result in o rows which when scanned will yield sql.ErrNoRows . The bavior of the above testcase is different.

since for some reason I get this

                ---- g
                "i"
                ---- e
                "i"
                []
                ----

IMHO they are both correct , just some minor issue from that gave us ---g part probably in the tests. I was not able to find a test case which returned 0 rows apart from these for #155

gernest commented 7 years ago

Oh! I think I found the fix. They are supposed to look like this

-- 1350 // https://github.com/cznic/ql/issues/155
BEGIN TRANSACTION;
    CREATE TABLE t (i int);
    INSERT INTO t VALUES (1);
    INSERT INTO t VALUES (2);
    INSERT INTO t VALUES (3);
COMMIT;
SELECT * FROM t WHERE EXISTS (SELECT * FROM t WHERE i == 4);
|"i"