Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PostgreSQL dialect fails to parse IN with union #1792

Open
adamchainz opened this issue Apr 2, 2025 · 0 comments · May be fixed by #1793
Open

PostgreSQL dialect fails to parse IN with union #1792

adamchainz opened this issue Apr 2, 2025 · 0 comments · May be fixed by #1793

Comments

@adamchainz
Copy link

adamchainz commented Apr 2, 2025

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 ---^
@adamchainz adamchainz linked a pull request Apr 2, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant