From 09ff27d3dedc6e6e21be9fc0f2a11cb5877f54d1 Mon Sep 17 00:00:00 2001 From: ad hoc Date: Mon, 11 Sep 2023 13:06:57 +0200 Subject: [PATCH] fix main compile error --- src/client.rs | 10 +++++----- src/local.rs | 26 +++++++++++++------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/client.rs b/src/client.rs index 76f9743..46852d2 100644 --- a/src/client.rs +++ b/src/client.rs @@ -57,7 +57,7 @@ impl Client { ) -> Result { match self { #[cfg(feature = "local_backend")] - Self::Local(l) => l.raw_batch(stmts), + Self::Local(l) => l.raw_batch(stmts).await, #[cfg(any( feature = "reqwest_backend", feature = "workers_backend", @@ -179,7 +179,7 @@ impl Client { pub async fn execute(&self, stmt: impl Into + Send) -> Result { match self { #[cfg(feature = "local_backend")] - Self::Local(l) => l.execute(stmt), + Self::Local(l) => l.execute(stmt).await, #[cfg(any( feature = "reqwest_backend", feature = "workers_backend", @@ -218,7 +218,7 @@ impl Client { ) -> Result { match self { #[cfg(feature = "local_backend")] - Self::Local(l) => l.execute_in_transaction(tx_id, stmt), + Self::Local(l) => l.execute_in_transaction(tx_id, stmt).await, #[cfg(any( feature = "reqwest_backend", feature = "workers_backend", @@ -235,7 +235,7 @@ impl Client { pub(crate) async fn commit_transaction(&self, tx_id: u64) -> Result<()> { match self { #[cfg(feature = "local_backend")] - Self::Local(l) => l.commit_transaction(tx_id), + Self::Local(l) => l.commit_transaction(tx_id).await, #[cfg(any( feature = "reqwest_backend", feature = "workers_backend", @@ -252,7 +252,7 @@ impl Client { pub(crate) async fn rollback_transaction(&self, tx_id: u64) -> Result<()> { match self { #[cfg(feature = "local_backend")] - Self::Local(l) => l.rollback_transaction(tx_id), + Self::Local(l) => l.rollback_transaction(tx_id).await, #[cfg(any( feature = "reqwest_backend", feature = "workers_backend", diff --git a/src/local.rs b/src/local.rs index 7298c5a..7baecad 100644 --- a/src/local.rs +++ b/src/local.rs @@ -93,7 +93,7 @@ impl Client { /// .raw_batch(["CREATE TABLE t(id)", "INSERT INTO t VALUES (42)"]); /// # } /// ``` - pub fn raw_batch( + pub async fn raw_batch( &self, stmts: impl IntoIterator>, ) -> anyhow::Result { @@ -109,7 +109,7 @@ impl Client { .map(libsql::Value::from) .collect::>() .into(); - let stmt = self.conn.prepare(sql_string)?; + let stmt = self.conn.prepare(sql_string).await?; let cols: Vec = stmt .columns() .into_iter() @@ -118,7 +118,7 @@ impl Client { }) .collect(); let mut rows = Vec::new(); - let input_rows = match stmt.query(¶ms) { + let mut input_rows = match stmt.query(¶ms).await { Ok(rows) => rows, Err(e) => { step_results.push(None); @@ -172,7 +172,7 @@ impl Client { /// /// # Arguments /// * `stmts` - SQL statements - pub fn batch( + pub async fn batch( &self, stmts: impl IntoIterator + Send> + Send, ) -> Result> { @@ -180,7 +180,7 @@ impl Client { std::iter::once(Statement::new("BEGIN")) .chain(stmts.into_iter().map(|s| s.into())) .chain(std::iter::once(Statement::new("END"))), - )?; + ).await?; let step_error: Option = batch_results .step_errors .into_iter() @@ -207,8 +207,8 @@ impl Client { /// # Arguments /// * `stmt` - the SQL statement - pub fn execute(&self, stmt: impl Into + Send) -> Result { - let results = self.raw_batch(std::iter::once(stmt))?; + pub async fn execute(&self, stmt: impl Into + Send) -> Result { + let results = self.raw_batch(std::iter::once(stmt)).await?; match (results.step_results.first(), results.step_errors.first()) { (Some(Some(result)), Some(None)) => Ok(ResultSet::from(result.clone())), (Some(None), Some(Some(err))) => Err(anyhow::anyhow!(err.message.clone())), @@ -216,15 +216,15 @@ impl Client { } } - pub fn execute_in_transaction(&self, _tx_id: u64, stmt: Statement) -> Result { - self.execute(stmt) + pub async fn execute_in_transaction(&self, _tx_id: u64, stmt: Statement) -> Result { + self.execute(stmt).await } - pub fn commit_transaction(&self, _tx_id: u64) -> Result<()> { - self.execute("COMMIT").map(|_| ()) + pub async fn commit_transaction(&self, _tx_id: u64) -> Result<()> { + self.execute("COMMIT").await.map(|_| ()) } - pub fn rollback_transaction(&self, _tx_id: u64) -> Result<()> { - self.execute("ROLLBACK").map(|_| ()) + pub async fn rollback_transaction(&self, _tx_id: u64) -> Result<()> { + self.execute("ROLLBACK").await.map(|_| ()) } }