Skip to content

IN with a subquery of two columns uses the first column: x IN (SELECT x, y FROM t1) #2757

Open

Description

@mathiasrw

IN (SELECT a, b ...) with a subquery of more than one column uses the first column. SQLite refuses it (sub-select returns 2 columns - expected 1). Seen in the sqllogictest run (evidence/in1.test), reproduced on develop (06211a0):

alasql('CREATE TABLE t1 (x INTEGER, y STRING)');
alasql("INSERT INTO t1 VALUES (1, 'true'), (0, 'false'), (NULL, 'NULL')");
alasql('SELECT x FROM t1 WHERE x IN (SELECT x, y FROM t1)');   // [{x: 1}, {x: 0}]
alasql('SELECT 1 FROM t1 WHERE 1 IN (SELECT 1, 2)');            // three rows

Breaking?

Yes, if it becomes an error: the result is consistent (the first column), so queries written this way work today.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions