Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit34a68c0

Browse files
authored
Merge pull requestrust-postgres#1142 from vsuryamurthy/add_simple_query_generic_client
add simple_query to GenericClient in tokio_postgres
2 parents20749d8 +d5d75d3 commit34a68c0

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed

‎tokio-postgres/CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Disable`rustc-serialize` compatibility of`eui48-1` dependency
66
* Remove tests for`eui48-04`
77
* Add`table_oid` and`field_id` fields to`Columns` struct of prepared statements.
8+
* Add`GenericClient::simple_query`.
89

910
##v0.7.10 - 2023-08-25
1011

‎tokio-postgres/src/generic_client.rs‎

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
usecrate::query::RowStream;
22
usecrate::types::{BorrowToSql,ToSql,Type};
3-
usecrate::{Client,Error,Row,Statement,ToStatement,Transaction};
3+
usecrate::{Client,Error,Row,SimpleQueryMessage,Statement,ToStatement,Transaction};
44
use async_trait::async_trait;
55

66
mod private{
@@ -12,25 +12,25 @@ mod private {
1212
/// This trait is "sealed", and cannot be implemented outside of this crate.
1313
#[async_trait]
1414
pubtraitGenericClient: private::Sealed{
15-
/// Like `Client::execute`.
15+
/// Like[`Client::execute`].
1616
asyncfnexecute<T>(&self,query:&T,params:&[&(dynToSql +Sync)]) ->Result<u64,Error>
1717
where
1818
T: ?Sized +ToStatement +Sync +Send;
1919

20-
/// Like `Client::execute_raw`.
20+
/// Like[`Client::execute_raw`].
2121
asyncfnexecute_raw<P,I,T>(&self,statement:&T,params:I) ->Result<u64,Error>
2222
where
2323
T: ?Sized +ToStatement +Sync +Send,
2424
P:BorrowToSql,
2525
I:IntoIterator<Item =P> +Sync +Send,
2626
I::IntoIter:ExactSizeIterator;
2727

28-
/// Like `Client::query`.
28+
/// Like[`Client::query`].
2929
asyncfnquery<T>(&self,query:&T,params:&[&(dynToSql +Sync)]) ->Result<Vec<Row>,Error>
3030
where
3131
T: ?Sized +ToStatement +Sync +Send;
3232

33-
/// Like `Client::query_one`.
33+
/// Like[`Client::query_one`].
3434
asyncfnquery_one<T>(
3535
&self,
3636
statement:&T,
@@ -39,7 +39,7 @@ pub trait GenericClient: private::Sealed {
3939
where
4040
T: ?Sized +ToStatement +Sync +Send;
4141

42-
/// Like `Client::query_opt`.
42+
/// Like[`Client::query_opt`].
4343
asyncfnquery_opt<T>(
4444
&self,
4545
statement:&T,
@@ -48,31 +48,34 @@ pub trait GenericClient: private::Sealed {
4848
where
4949
T: ?Sized +ToStatement +Sync +Send;
5050

51-
/// Like `Client::query_raw`.
51+
/// Like[`Client::query_raw`].
5252
asyncfnquery_raw<T,P,I>(&self,statement:&T,params:I) ->Result<RowStream,Error>
5353
where
5454
T: ?Sized +ToStatement +Sync +Send,
5555
P:BorrowToSql,
5656
I:IntoIterator<Item =P> +Sync +Send,
5757
I::IntoIter:ExactSizeIterator;
5858

59-
/// Like `Client::prepare`.
59+
/// Like[`Client::prepare`].
6060
asyncfnprepare(&self,query:&str) ->Result<Statement,Error>;
6161

62-
/// Like `Client::prepare_typed`.
62+
/// Like[`Client::prepare_typed`].
6363
asyncfnprepare_typed(
6464
&self,
6565
query:&str,
6666
parameter_types:&[Type],
6767
) ->Result<Statement,Error>;
6868

69-
/// Like `Client::transaction`.
69+
/// Like[`Client::transaction`].
7070
asyncfntransaction(&mutself) ->Result<Transaction<'_>,Error>;
7171

72-
/// Like `Client::batch_execute`.
72+
/// Like[`Client::batch_execute`].
7373
asyncfnbatch_execute(&self,query:&str) ->Result<(),Error>;
7474

75-
/// Returns a reference to the underlying `Client`.
75+
/// Like [`Client::simple_query`].
76+
asyncfnsimple_query(&self,query:&str) ->Result<Vec<SimpleQueryMessage>,Error>;
77+
78+
/// Returns a reference to the underlying [`Client`].
7679
fnclient(&self) ->&Client;
7780
}
7881

@@ -156,6 +159,10 @@ impl GenericClient for Client {
156159
self.batch_execute(query).await
157160
}
158161

162+
asyncfnsimple_query(&self,query:&str) ->Result<Vec<SimpleQueryMessage>,Error>{
163+
self.simple_query(query).await
164+
}
165+
159166
fnclient(&self) ->&Client{
160167
self
161168
}
@@ -243,6 +250,10 @@ impl GenericClient for Transaction<'_> {
243250
self.batch_execute(query).await
244251
}
245252

253+
asyncfnsimple_query(&self,query:&str) ->Result<Vec<SimpleQueryMessage>,Error>{
254+
self.simple_query(query).await
255+
}
256+
246257
fnclient(&self) ->&Client{
247258
self.client()
248259
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp