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
6 changes: 4 additions & 2 deletions src/SQLite.jl
Original file line number Diff line number Diff line change
Expand Up @@ -431,10 +431,12 @@ function bind!(stmt::Stmt, params::DBInterface.NamedStatementParams)
SQLiteException("values should be provided for all query placeholders"),
)
for i in 1:nparams
name = unsafe_string(C.sqlite3_bind_parameter_name(handle, i))
isempty(name) && throw(
# a nameless `?` parameter has a NULL name
nameptr = C.sqlite3_bind_parameter_name(handle, i)
nameptr == C_NULL && throw(
SQLiteException("nameless parameters should be passed as a Vector"),
)
name = unsafe_string(nameptr)
# name is returned with the ':', '@' or '$' at the start
sym = Symbol(name[2:end])
haskey(params, sym) || throw(
Expand Down
11 changes: 11 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,17 @@ end
SQLite.clear!(stmt)
end

@testset "Named values for a nameless placeholder" begin
db = SQLite.DB()
err = try
DBInterface.execute(db, "SELECT ? AS a", Dict(:a => 1))
catch e
e
end
@test err isa SQLiteException && occursin("nameless parameters", err.msg)
close(db)
end

@testset "Issue #180, Query" begin
param = "Hello!"
query = DBInterface.execute(
Expand Down
Loading