Skip to content

feat(to): table also for xlsx and ods#3580

Merged
jqnatividad merged 9 commits into
masterfrom
3568-to-table-also-for-xlsx-and-ods
Mar 5, 2026
Merged

feat(to): table also for xlsx and ods#3580
jqnatividad merged 9 commits into
masterfrom
3568-to-table-also-for-xlsx-and-ods

Conversation

@jqnatividad

Copy link
Copy Markdown
Collaborator

for #3568

jqnatividad and others added 6 commits March 5, 2026 06:06
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>

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

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 --table for to xlsx and to 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 --table behavior 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). If qsv to xlsx fails, the test may still pass/fail on stdout/file checks instead of clearly reporting the command failure. Prefer wrk.assert_success(&mut cmd) (or at least assert output.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 stdout from wrk.output(&mut cmd) without asserting the process exit status. Add an explicit success assertion (e.g., wrk.assert_success(&mut cmd) or assert!(output.status.success())) so failures in the to ods invocation 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}"
    );

Comment thread src/cmd/to.rs Outdated
jqnatividad and others added 3 commits March 5, 2026 07:49
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>
@jqnatividad jqnatividad merged commit 09c6e37 into master Mar 5, 2026
12 of 13 checks passed
@jqnatividad jqnatividad deleted the 3568-to-table-also-for-xlsx-and-ods branch March 5, 2026 12:56
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