callum-ryan commented on code in PR #534:
URL: https://github.com/apache/iceberg-rust/pull/534#discussion_r1722169292


##########
crates/catalog/sql/src/catalog.rs:
##########
@@ -141,21 +142,30 @@ impl SqlCatalog {
     }
 
     /// SQLX Any does not implement PostgresSQL bindings, so we have to do 
this.
-    pub async fn execute_statement(
-        &self,
-        query: &String,
-        args: Vec<Option<&String>>,
-    ) -> Result<Vec<AnyRow>> {
-        let query_with_placeholders: Cow<str> =
-            if self.sql_bind_style == SqlBindStyle::DollarNumeric {
-                let mut query = query.clone();
-                for i in 0..args.len() {
-                    query = query.replacen("?", &format!("${}", i + 1), 1);
-                }
-                Cow::Owned(query)
-            } else {
-                Cow::Borrowed(query)
-            };
+    fn replace_placeholders(&self, query: &str) -> String {
+        match self.sql_bind_style {
+            SqlBindStyle::DollarNumeric => {
+                let mut count = 1;
+                query
+                    .chars()
+                    .fold(String::with_capacity(query.len()), |mut acc, c| {
+                        if c == '?' {
+                            acc.push('$');
+                            acc.push_str(&count.to_string());
+                            count += 1;
+                        } else {
+                            acc.push(c);
+                        }
+                        acc
+                    })
+            }
+            _ => query.to_owned(),
+        }
+    }
+
+    /// Fetch a vec of AnyRows from a given query
+    pub async fn fetch_rows(&self, query: &str, args: Vec<Option<&str>>) -> 
Result<Vec<AnyRow>> {

Review Comment:
   removed!



##########
crates/catalog/sql/src/catalog.rs:
##########
@@ -167,43 +177,335 @@ impl SqlCatalog {
             .await
             .map_err(from_sqlx_error)
     }
+
+    /// Execute statements in a transaction, provided or not
+    pub async fn execute(

Review Comment:
   removed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to