feat(to): table also for xlsx and ods#3580
Merged
Merged
Conversation
Add examples to the xlsx/ods help showing --table usage and stdin support. Extend the --table help text to clarify it applies to postgres/sqlite and xlsx/ods and document name rules and limits. Change validation so --table is disallowed for datapackage but allowed for xlsx/ods; add sheet-name checks (xlsx max 31 chars, disallow \ / * [ ] : ?) while keeping postgres/sqlite identifier checks (start with letter/underscore, alnum/_ only, max 63). Wire up apply_table_rename when processing xlsx and ods inputs so provided table/sheet names are applied during conversion.
Co-Authored-By: Claude <claude@users.noreply.github.com>
- Apply the 31-character sheet name limit to both xlsx and ods (previously xlsx only), matching ODF spec conventions - Use chars().count() instead of len() for character-based length checking, so multi-byte UTF-8 names aren't rejected prematurely - Add test for ODS sheet name exceeding 31 characters - Update help text to clarify limit applies to both formats Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix xlsx too_long test to use "a".repeat(32) instead of "a]".repeat(16) which contained forbidden chars, masking the length validation check - Add output file existence assertions to xlsx and ods happy-path tests to ensure the command actually produces the expected file Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Extends the qsv to --table option so it can also control the worksheet name when converting to Excel (xlsx) and OpenDocument Spreadsheet (ods), in addition to existing database targets, addressing the workflow described in #3568.
Changes:
- Allow
--tableforto xlsxandto ods, using it as the sheet name (with basic validation). - Add/adjust integration tests for happy paths and sheet-name validation errors for xlsx/ods.
- Update help text/docs to describe
--tablebehavior for xlsx/ods and refine the datapackage restriction message.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/cmd/to.rs |
Adds xlsx/ods-specific --table validation and applies --table renaming for xlsx/ods conversions. |
tests/test_to.rs |
Adds new tests covering --table behavior for xlsx/ods and updates datapackage error expectation. |
docs/help/to.md |
Documents --table usage/examples for xlsx and ods. |
docs/help/TableOfContents.md |
Updates the Polars badge/hash reference in the help TOC. |
Comments suppressed due to low confidence (2)
tests/test_to.rs:555
- This test uses
wrk.output(&mut cmd)but never asserts the command succeeded (exit status). Ifqsv to xlsxfails, the test may still pass/fail on stdout/file checks instead of clearly reporting the command failure. Preferwrk.assert_success(&mut cmd)(or at least assertoutput.status.success()) before inspecting stdout/file existence.
let output = wrk.output(&mut cmd);
let stdout = String::from_utf8_lossy(&output.stdout);
assert!(
stdout.contains("My Sheet"),
"Expected sheet name 'My Sheet' in output, got: {stdout}"
);
tests/test_to.rs:647
- This test inspects
stdoutfromwrk.output(&mut cmd)without asserting the process exit status. Add an explicit success assertion (e.g.,wrk.assert_success(&mut cmd)orassert!(output.status.success())) so failures in theto odsinvocation are caught directly and produce clearer diagnostics.
let output = wrk.output(&mut cmd);
let stdout = String::from_utf8_lossy(&output.stdout);
assert!(
stdout.contains("My Sheet"),
"Expected sheet name 'My Sheet' in output, got: {stdout}"
);
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
`assert_success` and `output` both call `cmd.output()`, running the command twice. Replace with a single `output()` call followed by an inline status assertion, eliminating redundant execution and potential side-effect issues from the second run. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
for #3568