Move execute to Connection
This commit is contained in:
parent
38b491bffb
commit
643602d2b6
@ -579,6 +579,12 @@ impl Connection {
|
|||||||
.boxed()
|
.boxed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn execute(self, statement: &Statement, params: &[&ToSql]) -> BoxFuture<(u64, Connection), Error> {
|
||||||
|
self.raw_execute(&statement.name, "", &statement.params, params)
|
||||||
|
.and_then(|conn| conn.finish_execute())
|
||||||
|
.boxed()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn close(self) -> BoxFuture<(), Error> {
|
pub fn close(self) -> BoxFuture<(), Error> {
|
||||||
let mut terminate = vec![];
|
let mut terminate = vec![];
|
||||||
frontend::terminate(&mut terminate);
|
frontend::terminate(&mut terminate);
|
||||||
@ -615,15 +621,6 @@ impl Statement {
|
|||||||
pub fn columns(&self) -> &[Column] {
|
pub fn columns(&self) -> &[Column] {
|
||||||
&self.columns
|
&self.columns
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn execute(&self,
|
|
||||||
params: &[&ToSql],
|
|
||||||
conn: Connection)
|
|
||||||
-> BoxFuture<(u64, Connection), Error> {
|
|
||||||
conn.raw_execute(&self.name, "", &self.params, params)
|
|
||||||
.and_then(|conn| conn.finish_execute())
|
|
||||||
.boxed()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Row {
|
pub struct Row {
|
||||||
|
@ -112,12 +112,12 @@ fn prepare_execute() {
|
|||||||
.then(|c| {
|
.then(|c| {
|
||||||
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)| c.execute(&s, &[]))
|
||||||
.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)| c.execute(&s, &[&"steven", &"bob"]))
|
||||||
.map(|(n, _)| assert_eq!(n, 2));
|
.map(|(n, _)| assert_eq!(n, 2));
|
||||||
l.run(done).unwrap();
|
l.run(done).unwrap();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user