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

add simple_query to GenericClient in tokio_postgres#1142

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

Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletionstokio-postgres/CHANGELOG.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,6 +5,7 @@
* Disable `rustc-serialize` compatibility of `eui48-1` dependency
* Remove tests for `eui48-04`
* Add `table_oid` and `field_id` fields to `Columns` struct of prepared statements.
* Add `GenericClient::simple_query`.

## v0.7.10 - 2023-08-25

Expand Down
35 changes: 23 additions & 12 deletionstokio-postgres/src/generic_client.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
use crate::query::RowStream;
use crate::types::{BorrowToSql, ToSql, Type};
use crate::{Client, Error, Row, Statement, ToStatement, Transaction};
use crate::{Client, Error, Row,SimpleQueryMessage,Statement, ToStatement, Transaction};
use async_trait::async_trait;

mod private {
Expand All@@ -12,25 +12,25 @@ mod private {
/// This trait is "sealed", and cannot be implemented outside of this crate.
#[async_trait]
pub trait GenericClient: private::Sealed {
/// Like `Client::execute`.
/// Like[`Client::execute`].
async fn execute<T>(&self, query: &T, params: &[&(dyn ToSql + Sync)]) -> Result<u64, Error>
where
T: ?Sized + ToStatement + Sync + Send;

/// Like `Client::execute_raw`.
/// Like[`Client::execute_raw`].
async fn execute_raw<P, I, T>(&self, statement: &T, params: I) -> Result<u64, Error>
where
T: ?Sized + ToStatement + Sync + Send,
P: BorrowToSql,
I: IntoIterator<Item = P> + Sync + Send,
I::IntoIter: ExactSizeIterator;

/// Like `Client::query`.
/// Like[`Client::query`].
async fn query<T>(&self, query: &T, params: &[&(dyn ToSql + Sync)]) -> Result<Vec<Row>, Error>
where
T: ?Sized + ToStatement + Sync + Send;

/// Like `Client::query_one`.
/// Like[`Client::query_one`].
async fn query_one<T>(
&self,
statement: &T,
Expand All@@ -39,7 +39,7 @@ pub trait GenericClient: private::Sealed {
where
T: ?Sized + ToStatement + Sync + Send;

/// Like `Client::query_opt`.
/// Like[`Client::query_opt`].
async fn query_opt<T>(
&self,
statement: &T,
Expand All@@ -48,31 +48,34 @@ pub trait GenericClient: private::Sealed {
where
T: ?Sized + ToStatement + Sync + Send;

/// Like `Client::query_raw`.
/// Like[`Client::query_raw`].
async fn query_raw<T, P, I>(&self, statement: &T, params: I) -> Result<RowStream, Error>
where
T: ?Sized + ToStatement + Sync + Send,
P: BorrowToSql,
I: IntoIterator<Item = P> + Sync + Send,
I::IntoIter: ExactSizeIterator;

/// Like `Client::prepare`.
/// Like[`Client::prepare`].
async fn prepare(&self, query: &str) -> Result<Statement, Error>;

/// Like `Client::prepare_typed`.
/// Like[`Client::prepare_typed`].
async fn prepare_typed(
&self,
query: &str,
parameter_types: &[Type],
) -> Result<Statement, Error>;

/// Like `Client::transaction`.
/// Like[`Client::transaction`].
async fn transaction(&mut self) -> Result<Transaction<'_>, Error>;

/// Like `Client::batch_execute`.
/// Like[`Client::batch_execute`].
async fn batch_execute(&self, query: &str) -> Result<(), Error>;

/// Returns a reference to the underlying `Client`.
/// Like [`Client::simple_query`].
async fn simple_query(&self, query: &str) -> Result<Vec<SimpleQueryMessage>, Error>;

/// Returns a reference to the underlying [`Client`].
fn client(&self) -> &Client;
}

Expand DownExpand Up@@ -156,6 +159,10 @@ impl GenericClient for Client {
self.batch_execute(query).await
}

async fn simple_query(&self, query: &str) -> Result<Vec<SimpleQueryMessage>, Error> {
self.simple_query(query).await
}

fn client(&self) -> &Client {
self
}
Expand DownExpand Up@@ -243,6 +250,10 @@ impl GenericClient for Transaction<'_> {
self.batch_execute(query).await
}

async fn simple_query(&self, query: &str) -> Result<Vec<SimpleQueryMessage>, Error> {
self.simple_query(query).await
}

fn client(&self) -> &Client {
self.client()
}
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp