Skip to content

Extend Options' inputs validation#152

Merged
quinnj merged 1 commit intoJuliaData:mainfrom
Drvi:td-input-validation
Jan 4, 2023
Merged

Extend Options' inputs validation#152
quinnj merged 1 commit intoJuliaData:mainfrom
Drvi:td-input-validation

Conversation

@Drvi
Copy link
Copy Markdown
Collaborator

@Drvi Drvi commented Nov 15, 2022

This generalizes the compatibility checks between escapechar, openquotechar, closequotechar, delim and the sentinel values. We still fail to correctly validate pairs of regular expressions as those would have to be somehow reduced to their minimal canonical form (I'm sure there is a fancy CS name for this).

@codecov
Copy link
Copy Markdown

codecov bot commented Nov 15, 2022

Codecov Report

Base: 89.41% // Head: 89.41% // No change to project coverage 👍

Coverage data is based on head (0e62a95) compared to base (0e62a95).
Patch has no changes to coverable lines.

❗ Current head 0e62a95 differs from pull request most recent head d76ad07. Consider uploading reports for the commit d76ad07 to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #152   +/-   ##
=======================================
  Coverage   89.41%   89.41%           
=======================================
  Files           9        9           
  Lines        1549     1549           
=======================================
  Hits         1385     1385           
  Misses        164      164           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

quoted && (isempty(oq) || isempty(cq) || isempty(e)) && throw(ArgumentError("quoted=true requires openquotechar, closequotechar, and escapechar to be specified"))
sent = (sentinel === nothing || sentinel === missing) ? Token[] : map(x -> token(x, "sentinel"), prepare!(sentinel))
checksentinel = sentinel !== nothing
quoted && ((_match(openquotechar, delim) || _match(closequotechar, delim)) || _match(escapechar, delim)) &&
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, maybe the check should be about having a common prefix rather than equality?

@quinnj quinnj force-pushed the td-input-validation branch from 21c8b19 to d76ad07 Compare January 4, 2023 13:09
quinnj added a commit to JuliaData/CSV.jl that referenced this pull request Jan 4, 2023
Upon review of Parsers.Options validations ([ref](JuliaData/Parsers.jl#152)),
@nickrobinson251, @Drvi, and I agree that this shouldn't be valid. The problem is that there's
an ambiguity in the case of a _missing_ field vs. an empty quoted field vs. a quoted field
with newlines. For example:

```julia
a"b"c
1"2"3   # normal row
"2"3    # 1st field is missing, but ambiguous with 1st field as quoted `"2"`
"1""2"3 # Also ambiguous because the 2nd quote escapes the 3rd, so value is `1"2`
```
quinnj added a commit to JuliaData/CSV.jl that referenced this pull request Jan 4, 2023
Upon review of Parsers.Options validations ([ref](JuliaData/Parsers.jl#152)),
@nickrobinson251, @Drvi, and I agree that this shouldn't be valid. The problem is that there's
an ambiguity in the case of a _missing_ field vs. an empty quoted field vs. a quoted field
with newlines. For example:

```julia
a"b"c
1"2"3   # normal row
"2"3    # 1st field is missing, but ambiguous with 1st field as quoted `"2"`
"1""2"3 # Also ambiguous because the 2nd quote escapes the 3rd, so value is `1"2`
```
@quinnj quinnj merged commit 527ed05 into JuliaData:main Jan 4, 2023
quinnj added a commit to JuliaData/CSV.jl that referenced this pull request Jan 12, 2026
Upon review of Parsers.Options validations ([ref](JuliaData/Parsers.jl#152)),
@nickrobinson251, @Drvi, and I agree that this shouldn't be valid. The problem is that there's
an ambiguity in the case of a _missing_ field vs. an empty quoted field vs. a quoted field
with newlines. For example:

```julia
a"b"c
1"2"3   # normal row
"2"3    # 1st field is missing, but ambiguous with 1st field as quoted `"2"`
"1""2"3 # Also ambiguous because the 2nd quote escapes the 3rd, so value is `1"2`
```
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