- Notifications
You must be signed in to change notification settings - Fork514
Add methodsquery_typed_opt
,query_typed_one
andexecute_typed
#1265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -17,6 +17,13 @@ pub trait GenericClient: private::Sealed { | ||
where | ||
T: ?Sized + ToStatement; | ||
/// Like `Client::execute_typed`. | ||
fn execute_typed( | ||
&mut self, | ||
query: &str, | ||
params: &[(&(dyn ToSql + Sync), Type)], | ||
) -> Result<u64, Error>; | ||
/// Like `Client::query`. | ||
fn query<T>(&mut self, query: &T, params: &[&(dyn ToSql + Sync)]) -> Result<Vec<Row>, Error> | ||
where | ||
@@ -51,6 +58,20 @@ pub trait GenericClient: private::Sealed { | ||
params: &[(&(dyn ToSql + Sync), Type)], | ||
) -> Result<Vec<Row>, Error>; | ||
/// Like `Client::query_typed_one`. | ||
fn query_typed_one( | ||
&mut self, | ||
query: &str, | ||
params: &[(&(dyn ToSql + Sync), Type)], | ||
) -> Result<Row, Error>; | ||
/// Like `Client::query_typed_opt`. | ||
fn query_typed_opt( | ||
&mut self, | ||
query: &str, | ||
params: &[(&(dyn ToSql + Sync), Type)], | ||
) -> Result<Option<Row>, Error>; | ||
paolobarbolini marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
/// Like [`Client::query_typed_raw`] | ||
fn query_typed_raw<P, I>(&mut self, statement: &str, params: I) -> Result<RowIter<'_>, Error> | ||
where | ||
@@ -136,6 +157,22 @@ impl GenericClient for Client { | ||
self.query_typed(statement, params) | ||
} | ||
fn query_typed_one( | ||
&mut self, | ||
query: &str, | ||
params: &[(&(dyn ToSql + Sync), Type)], | ||
) -> Result<Row, Error> { | ||
self.query_typed_one(query, params) | ||
} | ||
fn query_typed_opt( | ||
&mut self, | ||
query: &str, | ||
params: &[(&(dyn ToSql + Sync), Type)], | ||
) -> Result<Option<Row>, Error> { | ||
self.query_typed_opt(query, params) | ||
} | ||
fn query_typed_raw<P, I>(&mut self, statement: &str, params: I) -> Result<RowIter<'_>, Error> | ||
where | ||
P: BorrowToSql, | ||
@@ -177,6 +214,14 @@ impl GenericClient for Client { | ||
fn transaction(&mut self) -> Result<Transaction<'_>, Error> { | ||
self.transaction() | ||
} | ||
fn execute_typed( | ||
&mut self, | ||
query: &str, | ||
params: &[(&(dyn ToSql + Sync), Type)], | ||
) -> Result<u64, Error> { | ||
self.execute_typed(query, params) | ||
} | ||
} | ||
impl private::Sealed for Transaction<'_> {} | ||
@@ -273,4 +318,28 @@ impl GenericClient for Transaction<'_> { | ||
fn transaction(&mut self) -> Result<Transaction<'_>, Error> { | ||
self.transaction() | ||
} | ||
fn query_typed_one( | ||
&mut self, | ||
query: &str, | ||
params: &[(&(dyn ToSql + Sync), Type)], | ||
) -> Result<Row, Error> { | ||
self.query_typed_one(query, params) | ||
} | ||
fn query_typed_opt( | ||
&mut self, | ||
query: &str, | ||
params: &[(&(dyn ToSql + Sync), Type)], | ||
) -> Result<Option<Row>, Error> { | ||
self.query_typed_opt(query, params) | ||
} | ||
Comment on lines +322 to +336 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. NIT: this should be moved up, just after | ||
fn execute_typed( | ||
&mut self, | ||
query: &str, | ||
params: &[(&(dyn ToSql + Sync), Type)], | ||
) -> Result<u64, Error> { | ||
self.execute_typed(query, params) | ||
} | ||
} |
Uh oh!
There was an error while loading.Please reload this page.