Reset as soon as possible.

This commit is contained in:
gwenn 2016-05-16 19:51:31 +02:00
parent 234624ae5c
commit 9fefa372db

View File

@ -24,11 +24,15 @@ impl<'conn> Statement<'conn> {
/// and `false` if the SQL returns an empty set. /// and `false` if the SQL returns an empty set.
pub fn exists(&mut self, params: &[&ToSql]) -> Result<bool> { pub fn exists(&mut self, params: &[&ToSql]) -> Result<bool> {
self.reset_if_needed(); self.reset_if_needed();
let mut rows = try!(self.query(params)); let exists = {
match rows.next() { let mut rows = try!(self.query(params));
Some(_) => Ok(true), match rows.next() {
None => Ok(false), Some(_) => Ok(true),
} None => Ok(false),
}
};
self.reset_if_needed();
return exists;
} }
} }