fix: paginate drops id from selective queries, orderBy mishandles system fields#41
Merged
Conversation
…tem fields
Three related bugs in the query builder:
1. FieldAccessTracker.record() allowed orderBy to overwrite a system field
(id, kind) as a props field, causing compileSelectiveProjection to emit
props->>'id' instead of the id column. This made paginate+select return
undefined for explicitly selected system fields.
2. orderBy() unconditionally wrapped every field as a props JSON path,
so ordering by system fields like id silently ordered by a nonexistent
JSON key instead of the actual column.
3. StringFieldAccessor lacked gt/gte/lt/lte operators, preventing keyset
cursor pagination via whereNode("a", (a) => a.id.lt(cursor)).
Fixes #40
0ee1b31 to
cdc9942
Compare
Merged
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.
.paginate()+.select():FieldAccessTracker.record()no longer allows a system field (id,kind) to be downgraded to a props field when#recordOrderByFieldsForPaginationre-records it, which caused the SQL projection to extract fromprops->>'id'(nonexistent) instead of theidcolumn.orderBy()for system fields:orderBy("alias", "id")now emitsORDER BY cte.alias_idinstead ofORDER BY json_extract(cte.alias_props, '$.id'). Also updated#buildCursorContextFromSelectiveRowto handle system field order specs for cursor construction.gt/gte/lt/ltetoStringFieldAccessor: Enables keyset cursor pagination viawhereNode("a", (a) => a.id.lt(cursor)).Fixes #40