Skip to content

Commit 50da3a7

Browse files
authored
Fix #144 by not requiring value dicts to only have named parameters. … (#191)
* Fix #144 by not requiring value dicts to only have named parameters. If the values dict doesn't have a named parameter, throw a helpful error * fix
1 parent 270fe53 commit 50da3a7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/SQLite.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,13 @@ function bind!(stmt::Stmt, values::Vector)
124124
end
125125
function bind!(stmt::Stmt, values::Dict{Symbol, V}) where {V}
126126
nparams = sqlite3_bind_parameter_count(stmt.handle)
127-
@assert nparams == length(values) "you must provide values for all query placeholders"
128127
for i in 1:nparams
129128
name = unsafe_string(sqlite3_bind_parameter_name(stmt.handle, i))
130129
@assert !isempty(name) "nameless parameters should be passed as a Vector"
131130
# name is returned with the ':', '@' or '$' at the start
132-
name = name[2:end]
133-
bind!(stmt, i, values[Symbol(name)])
131+
sym = Symbol(name[2:end])
132+
haskey(values, sym) || throw(SQLiteException("`$name` not found in values Dict to bind to sql statement"))
133+
bind!(stmt, i, values[sym])
134134
end
135135
end
136136
# Binding parameters to SQL statements

0 commit comments

Comments
 (0)