mirror of
https://github.com/isar/rusqlite.git
synced 2025-12-08 12:32:24 +08:00
Modify Rows::next to tie its lifetime to the returned Row.
This means Rows no longer implements Iterator, but it is no longer possible to misuse it by accessing a stale Row handle.
This commit is contained in:
@@ -90,7 +90,7 @@ impl<'conn> Statement<'conn> {
|
||||
unsafe { self.execute_() }
|
||||
}
|
||||
|
||||
/// Execute the prepared statement with named parameter(s), returning an iterator over the
|
||||
/// Execute the prepared statement with named parameter(s), returning a handle for the
|
||||
/// resulting rows. If any parameters that were in the prepared statement are not included in
|
||||
/// `params`, they will continue to use the most-recently bound value from a previous call to
|
||||
/// `query_named`, or `NULL` if they have never been bound.
|
||||
@@ -102,7 +102,7 @@ impl<'conn> Statement<'conn> {
|
||||
/// fn query(conn: &Connection) -> Result<()> {
|
||||
/// let mut stmt = try!(conn.prepare("SELECT * FROM test where name = :name"));
|
||||
/// let mut rows = try!(stmt.query_named(&[(":name", &"one")]));
|
||||
/// for row in rows {
|
||||
/// while let Some(row) = rows.next() {
|
||||
/// // ...
|
||||
/// }
|
||||
/// Ok(())
|
||||
@@ -117,6 +117,8 @@ impl<'conn> Statement<'conn> {
|
||||
Ok(Rows::new(self))
|
||||
}
|
||||
|
||||
// TODO: add query_map_named and query_and_then_named
|
||||
|
||||
fn bind_parameters_named(&mut self, params: &[(&str, &ToSql)]) -> Result<()> {
|
||||
for &(name, value) in params {
|
||||
if let Some(i) = try!(self.parameter_index(name)) {
|
||||
|
||||
Reference in New Issue
Block a user