Skip to content

Commit 643602d

Browse files
committed
Move execute to Connection
1 parent 38b491b commit 643602d

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

postgres-tokio/src/lib.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,12 @@ impl Connection {
579579
.boxed()
580580
}
581581

582+
pub fn execute(self, statement: &Statement, params: &[&ToSql]) -> BoxFuture<(u64, Connection), Error> {
583+
self.raw_execute(&statement.name, "", &statement.params, params)
584+
.and_then(|conn| conn.finish_execute())
585+
.boxed()
586+
}
587+
582588
pub fn close(self) -> BoxFuture<(), Error> {
583589
let mut terminate = vec![];
584590
frontend::terminate(&mut terminate);
@@ -615,15 +621,6 @@ impl Statement {
615621
pub fn columns(&self) -> &[Column] {
616622
&self.columns
617623
}
618-
619-
pub fn execute(&self,
620-
params: &[&ToSql],
621-
conn: Connection)
622-
-> BoxFuture<(u64, Connection), Error> {
623-
conn.raw_execute(&self.name, "", &self.params, params)
624-
.and_then(|conn| conn.finish_execute())
625-
.boxed()
626-
}
627624
}
628625

629626
pub struct Row {

postgres-tokio/src/test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,12 @@ fn prepare_execute() {
112112
.then(|c| {
113113
c.unwrap().prepare("CREATE TEMPORARY TABLE foo (id SERIAL PRIMARY KEY, name VARCHAR)")
114114
})
115-
.and_then(|(s, c)| s.execute(&[], c))
115+
.and_then(|(s, c)| c.execute(&s, &[]))
116116
.and_then(|(n, c)| {
117117
assert_eq!(0, n);
118118
c.prepare("INSERT INTO foo (name) VALUES ($1), ($2)")
119119
})
120-
.and_then(|(s, c)| s.execute(&[&"steven", &"bob"], c))
120+
.and_then(|(s, c)| c.execute(&s, &[&"steven", &"bob"]))
121121
.map(|(n, _)| assert_eq!(n, 2));
122122
l.run(done).unwrap();
123123
}

0 commit comments

Comments
 (0)