Skip to content

Commit f5b4876

Browse files
committed
Fix serialization in sqlreturn and more tests.
sqlreturn(::Any, ::Vector{UInt8}) was serializing values so any values passed to sqlreturn(::Any, ::Any) were being serialized twice. The net result of this being that they were returned as bytearrays.
1 parent 45c02cf commit f5b4876

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/UDF.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ sqlreturn(context, val::Int64) = sqlite3_result_int64(context, val)
3030
sqlreturn(context, val::Float64) = sqlite3_result_double(context, val)
3131
sqlreturn(context, val::UTF16String) = sqlite3_result_text16(context, val)
3232
sqlreturn(context, val::AbstractString) = sqlite3_result_text(context, val)
33-
sqlreturn(context, val::Vector{UInt8}) = sqlite3_result_blob(context, sqlserialize(val))
33+
sqlreturn(context, val::Vector{UInt8}) = sqlite3_result_blob(context, val)
3434

3535
sqlreturn(context, val::Bool) = sqlreturn(context, int(val))
3636
sqlreturn(context, val) = sqlreturn(context, sqlserialize(val))

test/runtests.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,14 @@ SQLite.register(db, hypot; nargs=2, name="hypotenuse")
189189
v = query(db, "select hypotenuse(Milliseconds,bytes) from track limit 5")
190190
@test [int(i) for i in v[1]] == [11175621,5521062,3997652,4339106,6301714]
191191

192+
SQLite.@register db str2arr(s) = convert(Array{UInt8}, s)
193+
r = query(db, "SELECT str2arr(LastName) FROM Employee LIMIT 2")
194+
@test r[1] == Any[UInt8[0x41,0x64,0x61,0x6d,0x73],UInt8[0x45,0x64,0x77,0x61,0x72,0x64,0x73]]
195+
196+
SQLite.@register db big
197+
r = query(db, "SELECT big(5)")
198+
@test r[1][1] == big(5)
199+
192200
@test size(tables(db)) == (11,1)
193201

194202
close(db)

0 commit comments

Comments
 (0)