Skip to content

Quote generated fields containing custom row separator characters - #374

Open
OskarEichler wants to merge 1 commit into
ruby:mainfrom
OskarEichler:codex/csv-quote-row-separator
Open

Quote generated fields containing custom row separator characters#374
OskarEichler wants to merge 1 commit into
ruby:mainfrom
OskarEichler:codex/csv-quote-row-separator

Conversation

@OskarEichler

Copy link
Copy Markdown

Summary

Include the configured row separator characters in the existing quote-detection pattern, matching the parser's treatment of those characters.

Reproduction

CSV.generate_line(["a|b", "x"], row_sep: "|") emits "a|b,x|", splitting one field into multiple records on a round trip. Standard CR/LF were already covered, but custom separators were not.

Verification

A 540-case corpus exercises both parse and incremental shift (1,080 checks) across three encodings, three column separators, three row separators and two quote characters. This isolated fix removes 119 of the release's 173 failing cases; 54 cases additionally require the separate shared-prefix parser fix. With both fixes, all 1,080 checks pass in both parser modes.

This isolated patch passes the unchanged upstream suite in both normal and CSV_PARSER_SCANNER_TEST=yes modes: 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 and git diff --check pass. The combined release-based consumer branch also passes gem build and rake 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

Output fields containing custom row separator characters now gain required quotes. Standard CR/LF output is unchanged. This does not alter :auto detection or address the separate shared-prefix parsing issue.

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.

1 participant