mirror of
https://github.com/fluencelabs/sqlite-wasm-connector
synced 2025-04-24 16:32:12 +00:00
Reset the state after Cursor’s bind
This commit is contained in:
parent
0e41f32222
commit
c5efaedc73
@ -11,6 +11,7 @@ pub struct Cursor<'l> {
|
||||
impl<'l> Cursor<'l> {
|
||||
/// Bind values to all parameters.
|
||||
pub fn bind(&mut self, values: &[Value]) -> Result<()> {
|
||||
self.state = None;
|
||||
try!(self.statement.reset());
|
||||
for (i, value) in values.iter().enumerate() {
|
||||
try!(self.statement.bind(i + 1, value));
|
||||
|
@ -76,8 +76,11 @@ fn cursor() {
|
||||
let mut cursor = ok!(connection.prepare(statement)).cursor().unwrap();
|
||||
|
||||
ok!(cursor.bind(&[Value::Integer(1)]));
|
||||
assert_eq!(ok!(ok!(cursor.next())), &[Value::Integer(1),
|
||||
Value::String("Alice".to_string())]);
|
||||
assert_eq!(ok!(ok!(cursor.next())), &[Value::Integer(1), Value::String("Alice".to_string())]);
|
||||
assert_eq!(ok!(cursor.next()), None);
|
||||
|
||||
ok!(cursor.bind(&[Value::Integer(1)]));
|
||||
assert_eq!(ok!(ok!(cursor.next())), &[Value::Integer(1), Value::String("Alice".to_string())]);
|
||||
assert_eq!(ok!(cursor.next()), None);
|
||||
|
||||
ok!(cursor.bind(&[Value::Integer(42)]));
|
||||
|
Loading…
x
Reference in New Issue
Block a user