Don't consume Statement

This commit is contained in:
Steven Fackler 2016-12-22 17:00:40 -05:00
parent 8b1034ad4e
commit 38b491bffb
2 changed files with 4 additions and 5 deletions

View File

@ -616,13 +616,12 @@ impl Statement {
&self.columns &self.columns
} }
pub fn execute(self, pub fn execute(&self,
params: &[&ToSql], params: &[&ToSql],
conn: Connection) conn: Connection)
-> BoxFuture<(u64, Statement, Connection), Error> { -> BoxFuture<(u64, Connection), Error> {
conn.raw_execute(&self.name, "", &self.params, params) conn.raw_execute(&self.name, "", &self.params, params)
.and_then(|conn| conn.finish_execute()) .and_then(|conn| conn.finish_execute())
.map(|(n, conn)| (n, self, conn))
.boxed() .boxed()
} }
} }

View File

@ -113,11 +113,11 @@ fn prepare_execute() {
c.unwrap().prepare("CREATE TEMPORARY TABLE foo (id SERIAL PRIMARY KEY, name VARCHAR)") c.unwrap().prepare("CREATE TEMPORARY TABLE foo (id SERIAL PRIMARY KEY, name VARCHAR)")
}) })
.and_then(|(s, c)| s.execute(&[], c)) .and_then(|(s, c)| s.execute(&[], c))
.and_then(|(n, _, c)| { .and_then(|(n, c)| {
assert_eq!(0, n); assert_eq!(0, n);
c.prepare("INSERT INTO foo (name) VALUES ($1), ($2)") c.prepare("INSERT INTO foo (name) VALUES ($1), ($2)")
}) })
.and_then(|(s, c)| s.execute(&[&"steven", &"bob"], c)) .and_then(|(s, c)| s.execute(&[&"steven", &"bob"], c))
.map(|(n, _, _)| assert_eq!(n, 2)); .map(|(n, _)| assert_eq!(n, 2));
l.run(done).unwrap(); l.run(done).unwrap();
} }