Repository navigation
fix(query): stop decode failures masquerading as NULL - #509
Merged
Merged
Conversation
extract_value decoded each cell with `.ok().flatten()`, collapsing three outcomes into one: a genuine SQL NULL, a successful decode, and a *failed* decode all became SqlValue::Null. The consequence was silent data loss. sqlx refuses DECIMAL entirely without the rust_decimal/bigdecimal feature, so every DECIMAL and NUMERIC column rendered as NULL — indistinguishable from a real one, nothing logged. YEAR did the same, matched in the DATE/DATETIME arm and asked to decode as a timestamp. Measured against MySQL 8 through the real execute path. Each arm now goes through decode_or_text, which keeps the three cases apart: a decode error falls back to the text MySQL sent and warns, so an unsupported type degrades visibly instead of vanishing. That closes the class, not just the two known instances. DECIMAL is read as text deliberately rather than via f64, which would defeat the exactness the type exists to provide. Also gates the binding export on beta-ai. Without the feature the AI commands are absent from the builder, so a plain `cargo test` quietly regenerated bindings.ts without them — which happened while verifying this change. DECIMAL now reaches the frontend as a string, so generated INSERTs quote it: better than the NULL it produced before, and resolved properly when quoting moves to column metadata (#502). closes #508 Co-Authored-By: Claude Opus 5 <[email protected]>
The tests selected from a type_probe table that existed only on my machine, so they failed in CI. Each test now creates and drops its own uniquely-named table, which also lets them run in parallel. Co-Authored-By: Claude Opus 5 <[email protected]>
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.
Closes #508. Step 1 of the restructure discussed on #502.
The bug
extract_valuedecoded each cell with.ok().flatten(), collapsing three different outcomes into one:A genuine SQL NULL, a successful decode, and a failed decode all came out as
SqlValue::Null.Measured against MySQL 8 through the real
executepath:sqlx refuses DECIMAL outright (built with
default-features = false, norust_decimal/bigdecimal), and YEAR was matched in theDATE | DATETIME | TIMESTAMP | TIME | YEARarm and asked to decode as a timestamp. Both failures were invisible — the grid, exports, copy-as-INSERT and generatedWHEREpredicates all saw NULL.The fix
Every arm now goes through
decode_or_text, which keeps the three cases apart. A decode error falls back to the text MySQL sent and logs a warning, so an unsupported type degrades visibly instead of vanishing. That closes the class rather than the two known instances — the next type sqlx can't handle shows up as text with a warning, not as a phantom NULL.DECIMAL reads as text deliberately, not via
f64:f64would defeat the exactness the column type exists to provide. Getting there needed sqlx'sDecodeimpl directly, sincetry_get::<String>also refuses DECIMAL (VARCHAR is not compatible with DECIMAL).Tests
crates/mas-core/tests/type_coverage.rs, against the real database:12345678901234.5678, nof64anywhere near itUInt(2026)Verified they fail without the fix: reverting
executor.rsturns the DECIMAL and YEAR tests red while the other two stay green.One extra fix
The binding export is now gated on
beta-ai. Without the feature the AI commands aren't in the builder, so a plaincargo testquietly regeneratedbindings.tswithout them — which happened to me while verifying this change. The pre-commit hook caught it, but the export shouldn't be able to write a partial file at all.Known follow-on
DECIMAL now arrives at the frontend as a string, so
toSqlLiteralquotes it in generated INSERTs. That's strictly better than theNULLit emitted before, and gets resolved properly in step 2, where quoting and alignment move toColumnMeta— the approach both SQLyog and Beekeeper Studio use.