Repository navigation
fix(query): render boolean columns as TRUE/FALSE, like bean-query - #2182
Conversation
`SELECT number > 0` returned `true` where bean-query returns `TRUE`, in
both CSV and the default text output. Any boolean-valued expression was
affected -- comparisons, IS NULL, IN -- and a script written against
bean-query that tests a field for `TRUE` silently matched nothing.
Not the one-line change it looked like. bean-query has TWO boolean
spellings, and `format_value`'s `Object` arm recurses:
a boolean COLUMN TRUE / FALSE
a boolean INSIDE a map True / False (Python repr)
Uppercasing the shared arm would have changed both, moving the nested
case further from bean-query than it already is. `format_value` now
applies the column rule and delegates everything else to
`format_value_nested`, which the set and object arms call so the
top-level spelling cannot leak into them.
JSON is untouched by construction -- it goes through
`serde_json::Value::Bool`, where `true` is the literal and `TRUE` would
be invalid -- and there is now a test saying so, because that is the
mistake a later "make it consistent" change would make.
Nothing covered any of this: all 454 tests passed before the change and
after it. Each of the three rules is confirmed to fail when reverted,
including the nested one, checked separately.
Closes #2179
There was a problem hiding this comment.
🟡 Changes recommended
The new tests don’t currently assert the boolean spelling in the default text output even though write_text also uses format_value, leaving the claimed behavior partially unpinned.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adjusts rustledger’s BQL query rendering to match bean-query’s boolean casing expectations for top-level result columns, preventing silent mismatches for consumers that compare against TRUE/FALSE (issue #2179).
Changes:
- Render
Value::BooleanasTRUE/FALSEfor top-level result columns. - Introduce
format_value_nested()so booleans inside sets/objects keep their prior lowercase rendering and the top-level rule doesn’t leak. - Add regression tests covering CSV top-level vs nested boolean rendering and JSON bool preservation.
File summaries
| File | Description |
|---|---|
| crates/rustledger/src/cmd/query/output.rs | Splits top-level vs nested value formatting to match bean-query’s boolean casing for result columns; adds targeted tests. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
📊 Benchmark Results
vs base, measured in this run
A difference counts only when it clears the combined spread of the two measurements, per shape (2σ: What do these numbers mean?
|
Review catch on #2182 from Copilot. The tests covered CSV and JSON but not the default text output, which shares format_value -- so a later change could keep CSV compatible and silently regress the format most users actually see. Confirmed the new assertion fails on a text-only regression, with the CSV assertion still passing.
✅ Compatibility Test Results
What's tested
Full results available in workflow artifacts |
What
SELECT number > 0returnedtruewhere bean-query returnsTRUE, in bothCSV and the default text output. Every boolean-valued expression was affected —
comparisons,
IS NULL,IN.The failure shape is the one this whole series keeps hitting: a script written
against bean-query that tests a field for
TRUEsilently matches nothing.No error, no missing column, just a comparison that never fires.
Not the one-line change it looked like
bean-query has two boolean spellings, and
format_value'sObjectarmrecurses:
TRUE/FALSETrue/False(Pythonrepr)Uppercasing the shared
Value::Booleanarm would have changed both, movingthe nested case further from bean-query than it already is. I measured that
before writing anything, which is the only reason it isn't in this diff.
format_valuenow applies the column rule and delegates everything else toformat_value_nested, which the set and object arms call — so the top-levelspelling cannot leak into them.
JSON
Untouched by construction: it goes through
serde_json::Value::Bool, wheretrueis the literal andTRUEwould make the document invalid. There is atest asserting it stays a real
bool, because "make it consistent" is exactlythe change someone would later make to that arm.
Verification
IS NULLandIN.not leak, not that our map format matches bean-query's (it does not; ours
omits the quoting).
after it. Each of the three rules is confirmed to fail when reverted,
including the nested one, checked separately.
known 34, found 34, new 0);corpus_paritydivergences still exactly 20, matching
main.Closes #2179