Skip to content

fix(component): unwrap query-value cells to the JSON-RPC shape#178

Merged
robcohen merged 1 commit into
mainfrom
feat/component-query-values
Jun 17, 2026
Merged

fix(component): unwrap query-value cells to the JSON-RPC shape#178
robcohen merged 1 commit into
mainfrom
feat/component-query-values

Conversation

@robcohen

Copy link
Copy Markdown
Member

Follow-up to #176 (part of #173). The generic marshaller renders BQL query cells as {"type": <case>, ...}, but RLCursor / the API serializer expect rustledger's value_to_json shape. So account cells came through as {"type":"text","value":...} dicts and inventory cells were empty {}.

Fix

_unwrap_query_value mirrors rustledger's value_to_json:

  • text / bool / int / date / string-set → bare scalar/list
  • number → {number}; amount → {number, currency}
  • inventory → {positions: [...]}; position/interval/metadata → fields un-tagged
  • json (object/set escape hatch) → parsed

Applied to the rows of query, query_entries, and session.query.

Impact

Full suite via the component (RUSTFAVA_RUSTLEDGER_BACKEND=component) drops query snapshot failures 17 → 12. The remaining 12 are narrow, root-caused divergences (position-dict key-order, a couple ledger-options defaults, error lineno 0-vs-None, one tree inventory bug) — tracked in #173. Default JSON-RPC path unaffected.

test_query updated to assert the unwrapped shape; ruff + mypy clean.

The generic marshaller renders BQL query cells as `{"type": <case>, ...}`,
but `RLCursor` / the API serializer expect rustledger's `value_to_json`
shape (text/bool/int as bare scalars, `number` as `{number}`, `amount` as
`{number, currency}`, `inventory` as `{positions: [...]}`, object/set via the
`json` escape hatch). The tagged form left account cells as dicts and
inventory cells empty.

Add `_unwrap_query_value` mirroring `value_to_json` and apply it to the rows
of `query`, `query_entries`, and `session.query`. Running the full suite via
the component drops the query snapshot failures (17 -> 12); the remainder are
narrow position-dict key-order / options-default / lineno divergences tracked
in #173.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant