fix(macros): sort offline query JSON keys - #4370
Open
Boulea7 wants to merge 1 commit into
Open
Conversation
Canonicalize every JSON object before writing offline query metadata so repeated prepare runs produce byte-stable files. Add recursive ordering, SQLite fixture, and cargo-sqlx prepare regression coverage. Developed with AI assistance.
Boulea7
force-pushed
the
fix/sqlx-4339-deterministic-query-json
branch
from
August 10, 2026 18:23
4e3712e to
a30eb56
Compare
Author
|
The failed SQLCipher job appears unrelated to this diff: a30eb56 and the previous green 4e3712e have identical trees, and all five SQLCipher tests passed before the exit-time segfault. The CI-equivalent command also passed locally, including 20 repeated host runs and 20 Ubuntu 24.04 runs; the same exit signature has occurred on unrelated branches. Could a maintainer please rerun the failed SQLite job or matrix? |
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.
Does your PR solve an issue?
Fixes #4339.
This makes
cargo sqlx prepareemit deterministic offline metadata by recursively sorting JSON object keys before writing. Array order and scalar values remain unchanged, and generated files retain their trailing newline.Is this a breaking change?
No. The generated JSON remains semantically equivalent; only object-key order becomes deterministic.
Testing
cargo +stable fmt --all -- --checkcargo test -p sqlx-macros-core --features 'macros,sqlite' query::data::tests::cargo test -p sqlx-cli --no-default-features --features sqlite --test prepare repeated_sqlite_prepare_is_byte_stableThe repository's pinned Rust 1.94 toolchain does not have the
rustfmtcomponent installed in this environment, so the formatting check used the installed stablerustfmt 1.9.0.AI assistance
This change was developed with AI assistance.