Skip to content
Permalink
Browse files
Ensure any AbstractString is serialized correctly
Fixes #53. The issue here is we had a couple of spots where `String` was
hard-coded instead of checking if a type was `<: AbstractString`. This
lead to the original issue in #53 where `SubString{String}` was
serialized as "binary" instead of as a string.
  • Loading branch information
quinnj committed Oct 28, 2020
1 parent 2e068c5 commit b48da43f103aa6089c584864ceb30c4a34bc08ca
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
@@ -98,7 +98,7 @@ function default end
default(T) = zero(T)
default(::Type{Symbol}) = Symbol()
default(::Type{Char}) = '\0'
default(::Type{String}) = ""
default(::Type{<:AbstractString}) = ""
default(::Type{Union{T, Missing}}) where {T} = default(T)

function default(::Type{A}) where {A <: AbstractVector{T}} where {T}
@@ -295,7 +295,7 @@ end
# arrowtype will call fieldoffset recursively for children
function arrowtype(b, x::List{T, O, A}) where {T, O, A}
if eltype(A) == UInt8
if T == String || T == Union{String, Missing}
if T <: AbstractString || T <: Union{AbstractString, Missing}
if O == Int32
Meta.utf8Start(b)
return Meta.Utf8, Meta.utf8End(b), nothing
@@ -138,6 +138,15 @@ tt = Arrow.Table(io)
@test length(tt) == length(t)
@test all(isequal.(values(t), values(tt)))

# 53
s = "a" ^ 100
t = (a=[SubString(s, 1:10), SubString(s, 11:20)],)
io = IOBuffer()
Arrow.write(io, t)
seekstart(io)
tt = Arrow.Table(io)
@test tt.a == ["aaaaaaaaaa", "aaaaaaaaaa"]

end # @testset "misc"

end

0 comments on commit b48da43

Please sign in to comment.