From 4d5eed832a4cf52be72b39606b5275ca3d4070bb Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Sat, 28 Nov 2015 20:59:47 -0800 Subject: [PATCH] Add query to Transaction and GenericConnection --- src/lib.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index fdeb0557..186e76d9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1209,6 +1209,11 @@ impl<'conn> Transaction<'conn> { self.conn.execute(query, params) } + /// Like `Connection::query`. + pub fn query<'a>(&'a self, query: &str, params: &[&ToSql]) -> Result> { + self.conn.query(query, params) + } + /// Like `Connection::batch_execute`. pub fn batch_execute(&self, query: &str) -> Result<()> { self.conn.batch_execute(query) @@ -1330,6 +1335,9 @@ pub trait GenericConnection { /// Like `Connection::execute`. fn execute(&self, query: &str, params: &[&ToSql]) -> Result; + /// Like `Connection::query`. + fn query<'a>(&'a self, query: &str, params: &[&ToSql]) -> Result>; + /// Like `Connection::transaction`. fn transaction<'a>(&'a self) -> Result>; @@ -1353,6 +1361,10 @@ impl GenericConnection for Connection { self.execute(query, params) } + fn query<'a>(&'a self, query: &str, params: &[&ToSql]) -> Result> { + self.query(query, params) + } + fn transaction<'a>(&'a self) -> Result> { self.transaction() } @@ -1379,6 +1391,10 @@ impl<'a> GenericConnection for Transaction<'a> { self.execute(query, params) } + fn query<'b>(&'b self, query: &str, params: &[&ToSql]) -> Result> { + self.query(query, params) + } + fn transaction<'b>(&'b self) -> Result> { self.transaction() }