From 287c0656d63bd2748ddf8efd4eac4caf7cf6cdaf Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Fri, 5 Jun 2026 15:57:48 -0500 Subject: [PATCH] Convert SQL args to compatible with the Python side ``` error[E0308]: mismatched types --> rust/src/storage/db/python_db_pool.rs:236:35 | 236 | self.execute(py, sql, args)?; | ------- ^^^^ expected `&Bound<'_, PyAny>`, found `&[&str]` | | | arguments to this method are incorrect | = note: expected reference `&pyo3::Bound<'_, pyo3::PyAny>` found reference `&'life2 [&'life3 str]` note: method defined here --> rust/src/storage/db/python_db_pool.rs:206:12 | 206 | pub fn execute<'py>( | ^^^^^^^ ... 210 | args: &Bound<'py, PyAny>, | ------------------------ ``` --- rust/src/storage/db/python_db_pool.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/rust/src/storage/db/python_db_pool.rs b/rust/src/storage/db/python_db_pool.rs index d7387ccb63..9dbd7cc8a5 100644 --- a/rust/src/storage/db/python_db_pool.rs +++ b/rust/src/storage/db/python_db_pool.rs @@ -18,7 +18,7 @@ //! - connections [`LoggingDatabaseConnectionWrapper`] which creates //! - transactions [`LoggingTransactionWrapper`] -use pyo3::{intern, prelude::*, types::PyCFunction}; +use pyo3::{intern, prelude::*, types::PyCFunction, types::PyList}; use crate::storage::db::{DatabaseConnection, DatabasePool, Row, Transaction}; @@ -233,8 +233,13 @@ impl LoggingTransactionWrapper { impl Transaction for LoggingTransactionWrapper { async fn query(&self, sql: &str, args: &[&str]) -> Result, anyhow::Error> { Python::attach(|py| -> PyResult> { - self.execute(py, sql, args).await; - let rows = self.fetchall(py, sql, args).await?; + // Convert the Rust `&[&str]` of SQL parameters into a Python sequence so it + // can be passed through to the Python-side `execute`. + let args = PyList::new(py, args)?; + // Run the query + self.execute(py, sql, args.as_any())?; + // Get the results + let rows = self.fetchall(py)?; Ok(rows) })