Add query to Transaction and GenericConnection
This commit is contained in:
parent
a3e967a4a1
commit
4d5eed832a
16
src/lib.rs
16
src/lib.rs
@ -1209,6 +1209,11 @@ impl<'conn> Transaction<'conn> {
|
|||||||
self.conn.execute(query, params)
|
self.conn.execute(query, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Like `Connection::query`.
|
||||||
|
pub fn query<'a>(&'a self, query: &str, params: &[&ToSql]) -> Result<Rows<'a>> {
|
||||||
|
self.conn.query(query, params)
|
||||||
|
}
|
||||||
|
|
||||||
/// Like `Connection::batch_execute`.
|
/// Like `Connection::batch_execute`.
|
||||||
pub fn batch_execute(&self, query: &str) -> Result<()> {
|
pub fn batch_execute(&self, query: &str) -> Result<()> {
|
||||||
self.conn.batch_execute(query)
|
self.conn.batch_execute(query)
|
||||||
@ -1330,6 +1335,9 @@ pub trait GenericConnection {
|
|||||||
/// Like `Connection::execute`.
|
/// Like `Connection::execute`.
|
||||||
fn execute(&self, query: &str, params: &[&ToSql]) -> Result<u64>;
|
fn execute(&self, query: &str, params: &[&ToSql]) -> Result<u64>;
|
||||||
|
|
||||||
|
/// Like `Connection::query`.
|
||||||
|
fn query<'a>(&'a self, query: &str, params: &[&ToSql]) -> Result<Rows<'a>>;
|
||||||
|
|
||||||
/// Like `Connection::transaction`.
|
/// Like `Connection::transaction`.
|
||||||
fn transaction<'a>(&'a self) -> Result<Transaction<'a>>;
|
fn transaction<'a>(&'a self) -> Result<Transaction<'a>>;
|
||||||
|
|
||||||
@ -1353,6 +1361,10 @@ impl GenericConnection for Connection {
|
|||||||
self.execute(query, params)
|
self.execute(query, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn query<'a>(&'a self, query: &str, params: &[&ToSql]) -> Result<Rows<'a>> {
|
||||||
|
self.query(query, params)
|
||||||
|
}
|
||||||
|
|
||||||
fn transaction<'a>(&'a self) -> Result<Transaction<'a>> {
|
fn transaction<'a>(&'a self) -> Result<Transaction<'a>> {
|
||||||
self.transaction()
|
self.transaction()
|
||||||
}
|
}
|
||||||
@ -1379,6 +1391,10 @@ impl<'a> GenericConnection for Transaction<'a> {
|
|||||||
self.execute(query, params)
|
self.execute(query, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn query<'b>(&'b self, query: &str, params: &[&ToSql]) -> Result<Rows<'b>> {
|
||||||
|
self.query(query, params)
|
||||||
|
}
|
||||||
|
|
||||||
fn transaction<'b>(&'b self) -> Result<Transaction<'b>> {
|
fn transaction<'b>(&'b self) -> Result<Transaction<'b>> {
|
||||||
self.transaction()
|
self.transaction()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user