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>,
    |         ------------------------
```
This commit is contained in:
Eric Eastwood
2026-06-05 15:57:48 -05:00
parent 7e709fb861
commit 287c0656d6
+8 -3
View File
@@ -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<Vec<Row>, anyhow::Error> {
Python::attach(|py| -> PyResult<Vec<Row>> {
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)
})