Preserve headers when copying an empty table - #367
Open
OskarEichler wants to merge 2 commits into
Open
Conversation
Member
Where is it written? |
Member
|
Do you have any real-world problem case by this? |
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
Pass the current headers to the new table in
by_col,by_row, andby_col_or_row. Preserve the existing shallow row-copy behavior.Reproduction
CSV.parse("a,b\n", headers: true).by_col.headersreturns[]instead of["a", "b"]; appending data then assigns nil headers. The same problem affects the other two non-mutating access-mode methods.Verification
48 focused checks: 18 failures on the release, zero with the patch, covering empty tables, duplicate/nil/symbol headers, appends, and original-table isolation.
This isolated patch passes the unchanged upstream suite in both normal and
CSV_PARSER_SCANNER_TEST=yesmodes: 527 tests / 4,050 assertions in each mode, zero failures/errors. Commands use Ruby 4.0.6 through rbenv (bundle exec ruby run-test.rb). Syntax andgit diff --checkpass. The combined release-based consumer branch also passes gem build andrake warning:error rdoc.No tests were added or changed, per the requesting project's explicit no-new-tests policy. Focused checks and measurements live outside this repository. The upstream no-RuboCop policy is respected. Verification was local on macOS/Ruby 4.0.6; the supported OS/Ruby matrix was not run locally. Current main and installed 3.3.6 share base commit
0873ab362d996f12796c3c3e8998b5be657a9b12; no unrelated changes are included.Breaking changes and limitations
None intended. Empty table copies now retain their headers. Row ownership semantics are unchanged.