Add named parameters support
SQLite supports named parameters in either of these forms:
- $NAME
- :NAME
- @NAME
These parameters should be supplied to the query either in a form of a map
or as a list, the key is always iodata:
- #{":myparam" => "value"}
- [{"$myparam", 1}]
- [{text, "@myparam", "value"}]
This commit is contained in:
@@ -42,6 +42,7 @@
|
||||
bind_text/3,
|
||||
bind_blob/3,
|
||||
bind_null/2,
|
||||
bind_parameter_index/2,
|
||||
|
||||
step/1,
|
||||
|
||||
@@ -194,6 +195,13 @@ bind_blob(_Statement, _Index, _Value) ->
|
||||
bind_null(_Statement, _Index) ->
|
||||
erlang:nif_error(nif_library_not_loaded).
|
||||
|
||||
-spec bind_parameter_index(Statement, ParameterName) -> Result when
|
||||
Statement :: esqlite3_stmt_ref(),
|
||||
ParameterName :: iodata(),
|
||||
Result :: {ok, integer()} | error.
|
||||
bind_parameter_index(_Statement, _ParameterName) ->
|
||||
erlang:nif_error(nif_library_not_loaded).
|
||||
|
||||
-spec step(Statement) -> StepResult when
|
||||
Statement :: esqlite3_stmt_ref(),
|
||||
StepResult :: row() | '$done' | error().
|
||||
|
||||
Reference in New Issue
Block a user