Skip to content

Commit 25f3702

Browse files
authored
fix string outputs from UDF (#250)
* fix string outputs from UDF * use first() instead of only()
1 parent 7c50014 commit 25f3702

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/api.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ end
274274
function sqlite3_result_text(context::Ptr{Cvoid}, value::AbstractString)
275275
return ccall( (:sqlite3_result_text, libsqlite),
276276
Cvoid, (Ptr{Cvoid}, Ptr{UInt8}, Cint, Ptr{Cvoid}),
277-
context, value, sizeof(value)+1, SQLITE_TRANSIENT)
277+
context, value, sizeof(value), SQLITE_TRANSIENT)
278278
end
279279
# SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
280280
# SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int n, void(*)(void*));

test/runtests.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,11 @@ SQLite.register(db, SQLite.regexp, nargs=2, name="regexp")
181181
r = DBInterface.execute(db, SQLite.@sr_str("SELECT LastName FROM Employee WHERE BirthDate REGEXP '^\\d{4}-08'")) |> columntable
182182
@test r[1][1] == "Peacock"
183183

184+
SQLite.register(db, identity, nargs=1, name="identity")
185+
r = DBInterface.execute(db, """SELECT identity("abc") as x, "abc" == identity("abc") as cmp""") |> columntable
186+
@test first(r.x) == "abc"
187+
@test first(r.cmp) == 1
188+
184189
@test_throws AssertionError SQLite.register(db, triple, nargs=186)
185190
SQLite.register(db, triple, nargs=1)
186191
r = DBInterface.execute(db, "SELECT triple(Total) FROM Invoice ORDER BY InvoiceId LIMIT 5") |> columntable

0 commit comments

Comments
 (0)