Repository navigation
Cursor paging: null-aware seek for nullable sort keys - #5836
Merged
Merged
Conversation
NULL never satisfies a comparison, so ascending paging dropped null rows and a descending cursor with a null boundary was rejected as invalid. Match PostgreSQL's NULLS LAST (ASC) / NULLS FIRST (DESC) ordering in the seek predicate and accept a null boundary when decoding the cursor. Fixes #5832 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.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.
Fixes #5832
Cursor paging dropped null rows ascending and threw
Invalid cursordescending for a nullable leading key holding nulls. Reproduced first (24 of 56 new cases red on ascending), then fixed:BuildSeekPredicate: per key, the 'after the boundary' term now follows PostgreSQL's ordering. Ascending non-null boundary:k > v OR k IS NULL; ascending null boundary: nothing follows, only tie-breakers; descending null boundary:k IS NOT NULL; descending non-null:k < v. Equality on a null boundary usesIS NULL.DecodeCursor: a JSON null boundary decodes to null for nullable/reference keys (stillInvalid cursorfor a non-nullable key).Tests:
int?,DateTime?,string, two nullable keys, and nullable strong-typedGuidId?, ascending and descending, nulls leading/inside/trailing/all-null/with ties, pageSize 2, compared with the unpaged query. Existing cursor suites (DocumentDbTests, ValueTypeTests, NodaTime) pass on net10.0.🤖 Generated with Claude Code