feat(query): NULL-aware after() position paging - #399
Merged
Conversation
after() accepts None in non-PK slots and expands the exclusive stepwise compare across NULL buckets so a pinned-first list can page from the last pinned row into unpinned rows in one query. Co-authored-by: Cursor <cursoragent@cursor.com>
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()now acceptsNonein every non-PK position slot (PKNoneis still a build-time error) and no longer consultsColumnSpec.nullable.exclusive_stepwise_compareis still the one expander: each key's direction,nulls=placement, and whether the bound is NULL fold into oneIS NULL/IS NOT NULL/ inequality tree so a cursor can cross the NULL bucket in one query."native"resolves at render fromDialect(Postgres: NULL is larger; SQLite: NULL is smaller). QueryIR stays at v13; a new golden pinskind: "null"inafter.Closes #394
Test plan
uv run pytest tests/test_after_position.py— build-time contract + SQLite backend-matrix e2e (Pinchnulls="last"DESC,after((None, id)), non-NULL cursor into the NULL bucket)cargo test --no-default-features --features testing query::— expander combinatorics (ASC/DESC × first/last × bound-NULL/non-NULL, native on both dialects, two keys)tests/test_query_wire_vectors.py,tests/test_ir_vectors_contract.py,cargo test -p ferro-schema-ir query_afteruv run ty check src/ferro/querypytest-postgresqlcould not start locally (pg_ctl initdbfailed). CI will run it.Made with Cursor