Skip to content

fix(query): PRINT falls back to spanned_directives (was empty in CLI) - #1508

Merged
robcohen merged 2 commits into
mainfrom
fix/bql-print-spanned-fallback
Jun 22, 2026
Merged

robcohen merged 2 commits into
mainfrom
fix/bql-print-spanned-fallback

Conversation

@robcohen

Copy link
Copy Markdown
Member

What

PRINT (and PRINT FROM …) returned 0 rows from rledger query — it emitted only a directive header. bean-query prints all directives.

Root cause (regression from #1506)

execute_print iterates self.directives, but the CLI builds the executor via Executor::new_with_sources (added in #1506 for the filename/lineno columns), which stores directives in spanned_directives and leaves self.directives empty. The system-table builders and other shorthands already fall back to spanned_directives; execute_print was the one path that didn't, so it saw an empty slice.

How

Add the same spanned_directives fallback the sibling methods use, so execute_print iterates whichever source is populated.

Tests

test_query_print_outputs_directives (CLI e2e): PRINT emits the directives (was empty). Full rustledger-query suite passes; clippy + fmt clean.

🤖 Generated with Claude Code

execute_print iterated self.directives, which is empty when the executor is
built via new_with_sources (the CLI path since #1506) — so PRINT returned 0
rows. Add the same spanned_directives fallback the system-table builders use.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@robcohen
robcohen requested a review from a team as a code owner June 22, 2026 02:37
Copilot AI review requested due to automatic review settings June 22, 2026 02:37
@codecov

codecov Bot commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a CLI regression where rledger query PRINT (and PRINT FROM …) returned zero rows because the CLI now constructs the query executor via Executor::new_with_sources, leaving self.directives empty and storing data in spanned_directives.

Changes:

  • Update execute_print to iterate whichever directive source is populated (directives vs spanned_directives).
  • Add a CLI end-to-end integration test covering PRINT output so the regression can’t recur.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
crates/rustledger-query/src/executor/execution.rs Make PRINT use the same spanned_directives fallback behavior as other executor paths.
crates/rustledger/tests/integration_test.rs Add an e2e regression test verifying rledger query PRINT emits directives.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

github-actions Bot commented Jun 22, 2026 •

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

Tool Time Memory
rustledger 37.5ms ± 5.8ms 23.5 MB
beancount 906.1ms ± 4.8ms 50.6 MB
Comparison 24.2x faster 2.2x less

vs main branch (2026-06-21)

Metric main this PR Change
Time 37.7ms 37.5ms -0.5% ✅
10K transactions · 5 runs, 2 warmup · hyperfine
What do these numbers mean?
  • Time: Wall-clock time to parse and validate the ledger (± std dev)
  • Memory: Peak resident set size (RSS)
  • vs main: Compared to latest nightly benchmark on main branch

@github-actions

github-actions Bot commented Jun 22, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Compatibility Test Results

Metric Result
Check Compatibility 100%
BQL Compatibility 85%
Full AST Match 100%
Total Files 792
What's tested
  • Check: Exit codes and error counts match bean-check
  • BQL: Query results match bean-query
  • Files: ~800 test files downloaded from 10+ beancount repositories

Full results available in workflow artifacts

Addresses Copilot on #1508 — avoids cross-run collisions on a fixed temp path;
NamedTempFile auto-removes (drops the explicit cleanup).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@robcohen
robcohen merged commit 07b01ae into main Jun 22, 2026
56 checks passed
@robcohen
robcohen deleted the fix/bql-print-spanned-fallback branch June 22, 2026 02:49
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.

2 participants