fix(python): key query rows in projection order - #1180
Merged
Merged
Conversation
thekevinscott
enabled auto-merge
September 24, 2026 21:01
Build each row dict from the core's query_ordered columns instead of iterating the row's HashMap, so the dict's insertion order is the order the SELECT list asked for.
thekevinbot
force-pushed
the
claude/1173-py-projection-order
branch
from
September 24, 2026 21:03
15d8fe0 to
9087a1a
Compare
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 #1173
db.query()returned dicts built by iterating the core's rowHashMap, so key order was hash order and changed from run to run. The binding now calls the core'squery_orderedand builds each dict by walkingcolumns, solist(row)is the order the SELECT list names (SELECT *follows the declared column order).API shape: no new surface. Python dicts keep insertion order, so the guarantee lives on the rows
query()already returns. A separatequery_orderedaccessor was the alternative; it was not added because the only thing it would add is a column list for a zero-row result.Red/green
The test commit (
f4e1847) went up alone. CI (dirsql Python CI / Binding tests, run 35994439070) failed on the new test for the asserted reason on 3.10, 3.12 and 3.13:Manual run
E2E Verification
packages/rustchange)packages/python/e2e-attestations/<branch>.jsonreceipt written ifpackages/pythonchanged (just e2e-attest-python)packages/ts/e2e-attestations/<branch>.jsonreceipt written ifpackages/tschanged (just e2e-attest-ts) — N/Ajust e2e-attest-python,uv run python -m pytest tests/integration/binding/,just preflightChangelog / Migrations
<root>/<pkg>/changelog.d/for each changed package (packages/python/changelog.d/2026-09-24-query-rows-in-projection-order.md)<root>/<pkg>/migrations.d/(packages/python/migrations.d/2026-09-24-query-rows-in-projection-order.md-- key order changes from per-process hash order to projection order; no code change required)Parity
Closes the last projection-order drift: Python rows are keyed in projection order; Rust and TypeScript expose
query_ordered/queryOrdered.PARITY.mdupdated;docs/reference/sdk.mdnotes the Python guarantee and points Rust and TypeScript callers atqueryOrdered.