Skip to content

Commit

Permalink
Treat empty quoted field as not empty sentinel for Strings (#139)
Browse files Browse the repository at this point in the history
* Treat empty quoted field as not empty sentinel for Strings

Implements #138.

The biggest question I have is whether we should view this as a bugfix
or a breaking change in behavior. I think it's arguable either way.

As a note, this doesn't break anything in current CSV.jl code,
which is maybe a signal that this change in behavior isn't super
common or makes that much of a difference?

cc: @nickrobinson251, @Drvi

* Update test/runtests.jl

Co-authored-by: Nick Robinson <npr251@gmail.com>

Co-authored-by: Nick Robinson <npr251@gmail.com>
  • Loading branch information
quinnj and nickrobinson251 committed Oct 21, 2022
1 parent 10b9503 commit 4a07611
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function emptysentinel(checksent::Bool)
function checkemptysentinel(::Type{T}, source, pos, len, b, code, pl) where {T}
Base.@_inline_meta
pos, code, pl, x = parser(T, source, pos, len, b, code, pl)
if checksent && pl.len == 0
if checksent && pl.len == 0 && (!isgreedy(T) || !quoted(code))
code &= ~(OK | INVALID)
code |= SENTINEL
pl = withmissing(pl)
Expand Down
3 changes: 2 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -541,8 +541,9 @@ showerror(io, e2)
res = Parsers.xparse(Float64, "\"\"", 1, 2)
@test Parsers.sentinel(res.code)

# #138
res = Parsers.xparse(String, "\"\"", 1, 2)
@test Parsers.sentinel(res.code)
@test !Parsers.sentinel(res.code)

# #38
@test Parsers.parse(Date, "25JUL1985", Parsers.Options(dateformat="dduuuyyyy")) == Date(1985, 7, 25)
Expand Down

0 comments on commit 4a07611

Please sign in to comment.