feat(query): order_by nulls placement e2e + golden vector - #367
Merged
Merged
Conversation
Pin mixed nulls=/omitted order_by terms on a dedicated Card fixture and assert cross-backend result order for root, left-join, and aggregate sorts. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
Author
|
Gate pass (coordinator). Golden |
3 tasks
0x054
added a commit
that referenced
this pull request
Aug 29, 2026
## Summary
Pin `NULL` sort-key placement on every `order_by()` with `nulls="first"
| "last"` (keyword-only). Native `NULLS FIRST` / `NULLS LAST` on
Postgres and SQLite. Omit the kwarg → backend default, no warning.
```python
cards = (
await Card.select()
.order_by(lambda card: card.pinned_at, "desc", nulls="last")
.order_by(lambda card: card.updated_at, "desc")
.all()
)
# ORDER BY pinned_at DESC NULLS LAST, updated_at DESC
```
- IR v7: optional `nulls` on an order_by term; key omitted when unset
- Python API on `Query` and `ProjectedQuery` (lambda, string, traversal,
aggregate, output alias)
- Golden vector + backend-matrix e2e
- Queries guide leads with pinned-first + rendered SQL; dialect split
stated once
Stacked: #365 (IR/SQL) → #366 (API) → #367 (e2e) → #368 (docs)
Closes #358
Closes #361
Closes #362
Closes #363
Closes #364
## Test plan
- [x] Slice CI green on each of #365–#368 (lint, rust, python, backend
matrix)
- [ ] Integration CI against `main`
- [ ] Confirm issues #358, #361–#364 close on merge to `main`
Made with [Cursor](https://cursor.com)
---------
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
query_card_nulls_v7golden vector (firstorder_byterm withnulls, next without;ir_version7) asserted from the Python emitter and Rust decoder; existing vectors unchanged.tests/test_order_by_nulls.py) pins identical row order on SQLite and Postgres forDESC+nulls="last",nulls="first", chained terms, left-joined relatedNOT NULLcolumns, and projectedSUMaggregates with NULL empty groups.nullsand restricts present values to"first"/"last".Closes #363
Test plan
uv run pytest tests/test_order_by_nulls.py tests/test_query_wire_vectors.py tests/test_ir_vectors_contract.py -qcargo test -p ferro-schema-irExit steps
Closes #363in PR body; assignee claimedMade with Cursor