Skip to content

feat(analysis): type LIMIT and OFFSET pagination placeholders - #31

Merged
omer-cengel merged 2 commits into
masterfrom
feature/typed-limit-and-offset-pagination
Sep 25, 2026
Merged

omer-cengel merged 2 commits into
masterfrom
feature/typed-limit-and-offset-pagination

Conversation

@omer-cengel

Copy link
Copy Markdown
Member

Summary

Read queries can now page their rows with parameterized LIMIT and OFFSET. Previously a $N placeholder in either clause was rejected as an unanalyzed location, and a named :n value was accepted but reached the executable SQL unbound.

Changes

  • A $N LIMIT row count becomes an Integer parameter named limit, and a $N OFFSET value becomes an Integer parameter named offset.
  • Pagination parameters are bound after every WHERE parameter, in textual order, so OFFSET $2 LIMIT $1 binds the offset first while the method still takes (limit, offset).
  • A literal or ALL value contributes no parameter, so LIMIT ALL OFFSET $1 binds only the offset and LIMIT 10 OFFSET 5 binds nothing.
  • A named LIMIT :n or OFFSET :n is rejected with the existing named-parameter diagnostic.
  • A placeholder in a computed value (LIMIT $1 + 1), in the LIMIT a, b form, or in FETCH FIRST $1 ROWS ONLY remains rejected.
  • Analyzer tests cover each form, and a PostgreSQL integration test executes both clause orders and checks that they return the same page.
  • The query reference documents pagination, its parameters, binding order, and rejected forms.

Scope and non-goals

  • Only SELECT pagination is analyzed; UPDATE and DELETE are unchanged.
  • Generated code does not validate values; PostgreSQL rejects a negative value when the query executes.
  • FETCH, LIMIT a, b, and computed pagination values are not supported with placeholders.
  • Code generation and the runtime are unchanged.

@omer-cengel
omer-cengel merged commit 0c55aa4 into master Sep 25, 2026
6 checks passed
@omer-cengel
omer-cengel deleted the feature/typed-limit-and-offset-pagination branch September 25, 2026 15:53
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