Skip to content

PostgreSQL dialect fails to parse IN with union #1792

Closed
@adamchainz

Description

@adamchainz

Minimal example:

SELECT 1 FROM t WHERE t.id IN ((SELECT id FROM t) UNION (SELECT id FROM t))

Currently, this fails with:

ParserError("Expected: ), found: UNION at Line: 1, Column: 51")

I checked this works on PostgreSQL shell:

postgres=# create table t(id int);
CREATE TABLE
postgres=# SELECT 1 FROM t WHERE t.id IN ((SELECT id FROM t) UNION (SELECT id FROM t));
 ?column?
----------
(0 rows)

And it fails to parse on SQLite:

sqlite> create table t(id int);
sqlite> SELECT 1 FROM t WHERE t.id IN ((SELECT id FROM t) UNION (SELECT id FROM t));
Parse error: near "UNION": syntax error
  SELECT 1 FROM t WHERE t.id IN ((SELECT id FROM t) UNION (SELECT id FROM t));
                                      error here ---^

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions