Skip to content

Commit

Permalink
fix size calculation, add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
maxfreu committed Apr 16, 2024
1 parent dc94b97 commit 77123dc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/SQLite.jl
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ function bind!(stmt::Stmt, i::Integer, val::Base.ReinterpretArray{UInt8, 1, T, <
_get_stmt_handle(stmt),
i,
val,
sizeof(val),
sizeof(eltype(val)) * length(val),
C.SQLITE_STATIC,
)
end
Expand Down
18 changes: 18 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,24 @@ end
close(db)
rm(dbfile)
end

@testset "ReinterpretArray" begin
binddb = SQLite.DB()
DBInterface.execute(
binddb,
"CREATE TABLE temp (b BLOB)",
)
DBInterface.execute(
binddb,
"INSERT INTO temp VALUES (?)",
[reinterpret(UInt8, [0x6f46, 0x426f, 0x7261]),],
)
rr = DBInterface.execute(rowtable, binddb, "SELECT b FROM temp")
@test length(rr) == 1
r = first(rr)
@test r.b == codeunits("FooBar")
@test typeof.(Tuple(r)) == (Vector{UInt8},)
end
end # @testset

struct UnknownSchemaTable end
Expand Down

0 comments on commit 77123dc

Please sign in to comment.