From e38e435665af8dbd55e7d803f019405653f99205 Mon Sep 17 00:00:00 2001 From: Ari Breitkreuz Date: Sun, 8 Jan 2023 12:21:42 +0100 Subject: [PATCH] add batch_execute to generic client --- tokio-postgres/src/generic_client.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tokio-postgres/src/generic_client.rs b/tokio-postgres/src/generic_client.rs index b2a90755..f05a422c 100644 --- a/tokio-postgres/src/generic_client.rs +++ b/tokio-postgres/src/generic_client.rs @@ -69,6 +69,10 @@ pub trait GenericClient: private::Sealed { /// Like `Client::transaction`. async fn transaction(&mut self) -> Result, Error>; + /// Like `Client::batch_execute`. + async fn batch_execute(&self, query: &str) -> Result<(), Error>; + + /// Returns a reference to the underlying `Client`. fn client(&self) -> &Client; } @@ -149,6 +153,10 @@ impl GenericClient for Client { self.transaction().await } + async fn batch_execute(&self, query: &str) -> Result<(), Error> { + self.batch_execute(query).await + } + fn client(&self) -> &Client { self } @@ -232,6 +240,10 @@ impl GenericClient for Transaction<'_> { self.transaction().await } + async fn batch_execute(&self, query: &str) -> Result<(), Error> { + self.batch_execute(query).await + } + fn client(&self) -> &Client { self.client() }