Repository navigation
feat(query): make meta selectable on #transactions - #2181
Conversation
The last of #2154's eleven columns. bean-query answers `SELECT meta FROM #transactions`; we returned nothing. Its `SELECT *` stays at seven columns, so this is wildcard-hidden -- the same split #2161 established for the other five per-table `meta` columns, and it means no existing output changes. User keys only. bean-query's per-table `meta` excludes `filename` and `lineno`; only `#entries` carries them (#2162), so this must not route through `augmented_meta`. A census of all 55 columns bean-query exposes across its ten system tables now finds three unselectable here, and all three need model changes rather than schema entries: #notes.tags, #notes.links Note drops them at parse time (#2160) #balances.discrepancy the balance checker computes it and does not store it on the directive (#2180) #2180 is filed as part of this, and the comment in `build_balances_table` that pointed at #2154 for `discrepancy` now points there instead, so the reference survives #2154 closing. The test asserts both halves -- selectable by name, absent from the wildcard -- and that the map carries no source keys. That last assertion needed a source-mapped executor to mean anything: with a plain `Executor::new` the location is None, `augmented_meta` returns its input unchanged, and routing this column through it passed the test. It fails now. Closes #2154
There was a problem hiding this comment.
🟢 Approval recommended
The change is narrowly scoped, preserves wildcard output shape via with_hidden, and includes a focused integration test that prevents the main regression modes.
Pull request overview
Adds the missing meta column to the #transactions system table in rustledger-query, making SELECT meta FROM #transactions behave like bean-query while keeping SELECT * FROM #transactions at the same 7-column shape (via per-table hidden columns).
Changes:
- Register
metaon#transactionsand mark it hidden from wildcard expansion (SELECT *). - Ensure
#transactions.metareturns user metadata only (does not route throughaugmented_meta, so nofilename/linenoinjection). - Add an integration test that pins both behaviors:
metais selectable, and wildcard stays at seven columns.
File summaries
| File | Description |
|---|---|
| crates/rustledger-query/src/executor/system_tables.rs | Adds meta to #transactions table schema, hides it from SELECT *, and documents discrepancy issue reference update (#2180). |
| crates/rustledger-query/tests/bql_integration_test.rs | Adds a source-mapped regression test ensuring #transactions.meta is selectable, hidden from wildcard, and excludes filename/lineno. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- 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✅ All modified and coverable lines are covered by tests. 📢 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?
|
✅ Compatibility Test Results
What's tested
Full results available in workflow artifacts |
Self-review catch on #2181. The test was switched to `new_with_sources` so the "no source keys" assertion could actually fail -- with a plain `Executor::new` the location is None and `augmented_meta` is a no-op. That fixed one gap and opened another: the plain path is what wasm and the FFI use, and it was then covered by nothing. Both are asserted now. All four ways to get the column wrong -- dropping it, making it wildcard-visible, routing it through `augmented_meta`, nulling the value -- fail the test, checked one at a time.
…data Third review pass on #2181 found no defect; this locks in what it checked. The same transaction is visible through `#transactions.meta`, `#entries.meta` and `#postings._entry_meta`. `#entries` adds `filename`/`lineno` and the other two do not -- that split is bean-query's and is already asserted -- but the user's own keys are one fact and must not differ by which table you ask. Nothing tested that. A per-table census cannot see it either: every column involved is present in every table, so the disagreement is in the values. That is exactly how #entries and #documents came to report different tags for one directive (#2161). Confirmed the assertion fails when `#entries.meta` is made to drop the user's keys.
What
The last of #2154's eleven columns. bean-query answers
SELECT meta FROM #transactions; we returned nothing.Wildcard-hidden, because bean-query keeps
SELECT * FROM #transactionsatseven columns — the same split #2161 established for the other five per-table
metacolumns. No existing output changes, so no snapshot drift anywhere.User keys only: bean-query's per-table
metaexcludesfilename/lineno,which only
#entriescarries (#2162), so this must not route throughaugmented_meta.#2154 is now complete, and what remains is a different kind of problem
A census of all 55 columns bean-query exposes across its ten system tables
finds three unselectable here — with a negative control confirming the census
detects a genuinely absent column:
#notes.tags,#notes.linksNotedrops them at parse time (#2160)#balances.discrepancyNeither is a schema-registration gap, which is what #2154 was about. #2180 is
filed as part of this PR, and the comment in
build_balances_tablethatpointed at #2154 for
discrepancynow points there instead, so the referencesurvives #2154 closing.
The test needed a real SourceMap to mean anything
It asserts three things:
metaresolves by name,SELECT *stays at sevencolumns, and the map carries no source keys.
That third assertion was decorative at first. With a plain
Executor::newthere is no source location, soaugmented_metareturns itsinput unchanged — I mutated the column to route through it and the test still
passed. The fixture now builds a source-mapped executor, and that mutation
fails.
All three ways to get this wrong are covered, checked one at a time:
with_hiddendebug assertion from perf(query): skip #postings columns the query cannot observe #2174)SELECT *→ caughtaugmented_meta→ caught, once the fixture was realCost of building it unconditionally
The column is built for every row, like the other five per-table
metacolumns. Measured rather than assumed, against a binary built from
main,--no-cache, interleaved:count(date) FROM #transactionsSELECT * FROM #transactionscount(date) FROM #transactionsSo the worst case is ~30 ms on a deliberately extreme shape, for a query that
never selects
meta. Far from the 40% that justified the projection gating in#2169, so that machinery is not worth the review surface here. The number is
recorded at the code so a future reader deciding otherwise has it.
Verification
SELECT *parity across all ten tables unchanged: 6 match, 4 differ, exactlyas before this PR.
known 34, found 34, new 0).Closes #2154