feat(query): after(position) for non-null root order keys - #398
Merged
Conversation
Page a query whose order keys are root columns, include the primary key, and are all non-nullable. Exclusive stepwise compare lives in one Rust function so #394 can extend it; datetime query binds use pydantic JSON so SQLite TEXT equality matches INSERT. Co-authored-by: Cursor <cursoragent@cursor.com>
#392 made order_by.nulls required; three inline payloads still omitted it and cargo test failed deserialize on CI. Co-authored-by: Cursor <cursoragent@cursor.com>
OrderByEntry.nulls is str after #392; the helper already normalizes before the call, so the parameter should not accept None. Co-authored-by: Cursor <cursoragent@cursor.com>
ADR-0017 made omitted nulls= last on every dialect. The left_join order test still asserted SQLite's native NULLs-first ASC. Co-authored-by: Cursor <cursoragent@cursor.com>
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
after(position)pages a query whose order keys are root columns, include the primary key, and are all non-nullable. The bound is exclusive.position_of(row)reads that tuple;after(row)is sugar forafter(position_of(row)).afterbound as typedkind/valuenodes (omitted when unset).count()drops paging the same way it drops limit/offset;update/deleterejectafter.after+offsetis a build-time error (two starts).(a > :a) OR (a = :a AND b > :b), DESC flipping the inequality — so NULL-aware after() #394 can extend that function. Datetime query binds use pydantic JSON (…Zfor UTC) so SQLite TEXT equality matches INSERT.Test plan
Nonein a slot;after+offset;update/deleterejectafter;count()omitsafterorder_by(updated_at).order_by(id).after((ts, id)).limit(n)returns the next n exclusive, in declared order; empty page past the end;after(row)equalsafter(position_of(row))query_user_after_v13plus all query vectors bumped toir_version13FERRO_POSTGRES_URL)Closes #393
Made with Cursor