fix(sqlite): argument bind for sqlite is 1-indexed

fixes #467
This commit is contained in:
Ryan Leckey
2020-07-02 22:52:21 -07:00
parent 72700615c8
commit c7c46f237b
3 changed files with 39 additions and 5 deletions

View File

@@ -55,7 +55,7 @@ impl SqliteArguments<'_> {
let mut arg_i = 0;
for handle in &statement.handles {
let cnt = handle.bind_parameter_count();
for param_i in 0..cnt {
for param_i in 1..=cnt {
// figure out the index of this bind parameter into our argument tuple
let n: usize = if let Some(name) = handle.bind_parameter_name(param_i) {
if name.starts_with('?') {
@@ -77,7 +77,7 @@ impl SqliteArguments<'_> {
));
}
self.values[n - 1].bind(handle, param_i + 1)?;
self.values[n - 1].bind(handle, param_i)?;
}
}

View File

@@ -142,6 +142,7 @@ impl StatementHandle {
}
// Name Of A Host Parameter
// NOTE: The first host parameter has an index of 1, not 0.
#[inline]
pub(crate) fn bind_parameter_name(&self, index: usize) -> Option<&str> {
unsafe {