Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/array_parsing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ function parse_unquoted(code::Base.CodeUnits{UInt8, String}, pos::Ref{Int})
pos[] += 1
end
end
return String(strip(String(buf)))
# The server quotes any element that contains ASCII whitespace, so an
# unquoted element runs to the delimiter. Unicode spaces such as U+00A0
# are never quoted and belong to the element: do not strip.
return String(buf)
end

function parse_bool_token(token::String)
Expand Down
7 changes: 7 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1371,6 +1371,13 @@ include("trim_compile_tests.jl")
bracket_param = ["a]b", "x[1]", "]", "plain"]
bracket_row = only(Tables.rowtable(DBInterface.execute(conn, raw"SELECT $1::text[] AS arr", (bracket_param,))))
@test bracket_row.arr == bracket_param
# PostgreSQL quotes an element only for ASCII whitespace, so
# other whitespace at an element's edge arrives unquoted
edge_ws = ["\u00a0lead", "trail\u00a0", "\u2028both\u3000", "a b"]
edge_row = only(Tables.rowtable(DBInterface.execute(conn,
raw"SELECT ARRAY[E'\u00a0lead', E'trail\u00a0', E'\u2028both\u3000', 'a b'] AS arr")))
@test edge_row.arr == edge_ws
@test DBInterface.execute(conn, raw"SELECT $1::text[] AS arr", (edge_ws,), NamedTuple{(:arr,), Tuple{Vector{String}}}).arr == edge_ws
array_row = only(Tables.rowtable(DBInterface.execute(conn, "SELECT '{1,NULL,3}'::int[] AS arr")))
@test isequal(array_row.arr, Union{Missing, Int32}[1, missing, 3])
nested_row = only(Tables.rowtable(DBInterface.execute(conn, "SELECT '{{1,2},{3,4}}'::int[] AS arr")))
Expand Down
Loading