mirror of
https://github.com/isar/rusqlite.git
synced 2026-01-08 03:42:24 +08:00
Reset in Rows's drop impl instead of waiting for the next query
This commit is contained in:
@@ -23,16 +23,14 @@ impl<'conn> Statement<'conn> {
|
||||
/// Return `true` if a query in the SQL statement it executes returns one or more rows
|
||||
/// and `false` if the SQL returns an empty set.
|
||||
pub fn exists(&mut self, params: &[&ToSql]) -> Result<bool> {
|
||||
self.reset_if_needed();
|
||||
let mut rows = try!(self.query(params));
|
||||
let exists = {
|
||||
let mut rows = try!(self.query(params));
|
||||
match rows.next() {
|
||||
Some(_) => Ok(true),
|
||||
None => Ok(false),
|
||||
Some(_) => true,
|
||||
None => false,
|
||||
}
|
||||
};
|
||||
self.reset_if_needed();
|
||||
return exists;
|
||||
Ok(exists)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user