fix(cli): render history records in table/csv output#1378
Open
bplatz wants to merge 1 commit into
Open
Conversation
The history query projects a select list, so the engine returns each row
as a positional JSON array ([?p, ?v, ?t, ?op], or [?v, ?t, ?op] when
filtered to a single predicate). The table and CSV formatters instead
read each row as an object (row.get("?t"), etc.), so every lookup
returned None: blank t/value cells, a '?' op placeholder, and a missing
predicate column. --format json was unaffected because it prints the raw
array.
Add a HistoryRow accessor that reads rows positionally by array length
(still tolerating object-keyed rows) and route both formatters through
it. Cover the formatters with unit tests for both array shapes plus an
integration assertion that the default table renders populated cells.
Closes #1367
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.
Summary
fluree history <entity>with the default (table) output rendered blank cells and?placeholders instead of the history records, even though--format jsonreturned correct data (#1367).Root cause
History queries project a select list, so the engine returns each row as a positional JSON array:
[?p, ?v, ?t, ?op]--predicatefilter:[?v, ?t, ?op]The table and CSV formatters instead read each row as an object (
row.get("?t"),row.get("?op"), …). On an array every lookup returnsNone, producing blankt/valuecells, a?op placeholder (theunwrap_or("?")), and a missing predicate column.--format jsonwas unaffected because it prints the raw array verbatim. The gap slipped through because existing history tests only exercised--format json.Fix
HistoryRowaccessor that reads rows positionally by array length (4 →[p,v,t,op], 3 →[v,t,op]), still tolerating object-keyed rows defensively.Output after the fix
Tests
history_shows_changesintegration test to assert the default table renders populated cells (no?), exercising the real local query path.cargo fmt+clippy --all-features --all-targets -D warningsclean.Closes #1367