Skip to content

Commit 77b9430

Browse files
committed
Fix erroneous varchar whitespace stripping
1 parent 95703d0 commit 77b9430

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/parsing.jl

+3-2
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ is not in UTF-8.
101101
bytes_view(pqv::PQValue) = unsafe_wrap(Vector{UInt8}, data_pointer(pqv), num_bytes(pqv) + 1)
102102

103103
Base.String(pqv::PQValue) = unsafe_string(pqv)
104+
Base.parse(::Type{String}, pqv::PQValue) = unsafe_string(pqv)
104105
Base.convert(::Type{String}, pqv::PQValue) = String(pqv)
105106
Base.length(pqv::PQValue) = length(string_view(pqv))
106107
Base.lastindex(pqv::PQValue) = lastindex(string_view(pqv))
@@ -153,8 +154,8 @@ _DEFAULT_TYPE_MAP[:numeric] = Decimal
153154

154155
## character
155156
# bpchar is char(n)
156-
function pqparse(::Type{String}, str::AbstractString)
157-
return String(rstrip(str, ' '))
157+
function Base.parse(::Type{String}, pqv::PQValue{PQ_SYSTEM_TYPES[:bpchar]})
158+
return String(rstrip(string_view(pqv), ' '))
158159
end
159160
# char is "char"
160161
_DEFAULT_TYPE_MAP[:char] = PQChar

test/runtests.jl

+2
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,8 @@ end
11011101
("E'\\\\001'::bytea", UInt8[0o001]),
11021102
("E'\\\\176'::bytea", UInt8[0o176]),
11031103
("'hello'::char(10)", "hello"),
1104+
("'hello '::char(10)", "hello"),
1105+
("'hello '::varchar(10)", "hello "),
11041106
("'3'::\"char\"", LibPQ.PQChar('3')),
11051107
("'t'::bool", true),
11061108
("'T'::bool", true),

0 commit comments

Comments
 (0)