Skip to content

Merge a parenthesized query with the clauses around it - #147

Merged
LucaCappelletti94 merged 1 commit into
mainfrom
fix/root-query-parentheses
Oct 24, 2026
Merged

LucaCappelletti94 merged 1 commit into
mainfrom
fix/root-query-parentheses

Conversation

@LucaCappelletti94

Copy link
Copy Markdown
Collaborator

PostgreSQL treats the clauses around a parenthesized query as clauses of that query, so (SELECT 0) runs and (SELECT a FROM q ORDER BY id LIMIT 2) OFFSET 1 is one query with LIMIT 2 OFFSET 1. SQLite has no parenthesized query, so the output failed with near "(", at the statement root and inside a derived table alike.

The translator now merges a directly nested query body with its outer clauses before translating it. A clause given on both sides is refused with PostgreSQL's own multiple ... clauses not allowed, since sqlparser accepts what PostgreSQL rejects. Compound operands keep their existing handling.

PostgreSQL treats the clauses around a parenthesized query as clauses of that query, so `(SELECT 0)` runs and `(SELECT a FROM q ORDER BY id LIMIT 2) OFFSET 1` is one query with `LIMIT 2 OFFSET 1`. SQLite has no parenthesized query, so the output failed with `near "("`, at the statement root and inside a derived table alike.

The translator now merges a directly nested query body with its outer clauses before translating it. A clause given on both sides is refused with PostgreSQL's own `multiple ... clauses not allowed`, since sqlparser accepts what PostgreSQL rejects. Compound operands keep their existing handling.
@LucaCappelletti94 LucaCappelletti94 added the bug Something isn't working label Oct 23, 2026
@codecov

codecov Bot commented Oct 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.36066% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/impls/translator_impls/query.rs 98.36% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@LucaCappelletti94
LucaCappelletti94 merged commit adf5b12 into main Oct 24, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant