Skip to content

Read outer pagination from set-operation queries - #724

Open
pengpengyi92 wants to merge 1 commit into
macbre:masterfrom
pengpengyi92:fix/set-operation-pagination-20261112
Open

pengpengyi92 wants to merge 1 commit into
macbre:masterfrom
pengpengyi92:fix/set-operation-pagination-20261112

Conversation

@pengpengyi92

Copy link
Copy Markdown

limit_and_offset descends into the first SELECT even when the AST root is a
set operation. This reports a branch's pagination instead of the outer one:

Parser("(SELECT id FROM a LIMIT 10) UNION SELECT id FROM b LIMIT 5 OFFSET 2").limit_and_offset
# current: (10, 0); expected: (5, 2)

Treat exp.SetOperation like exp.Select when choosing the pagination owner.
The existing fallback and non-set-operation behavior are deliberately unchanged;
this is not a general rewrite of nested-query LIMIT semantics.

Added 10 cases across UNION, UNION ALL, INTERSECT and EXCEPT, either limited
branch, repeated property access, zero limit and omitted offset. Before the fix:
10 failed, 12 passed in the focused module. Full suite after the fix:
302 passed, 100% coverage. Mypy and Ruff lint pass. Full-file formatter checks
report existing unrelated differences, not new formatting changes.

AI-assisted with OpenAI Codex; no independent human review is claimed.

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 this pull request may close these issues.

1 participant