mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-11 04:04:20 +01:00
make all run_once be run under statement or connection so that rollback is called
This commit is contained in:
@@ -96,14 +96,12 @@ impl Cursor {
|
||||
// For DDL and DML statements,
|
||||
// we need to execute the statement immediately
|
||||
if stmt_is_ddl || stmt_is_dml || stmt_is_tx {
|
||||
let mut stmt = stmt.borrow_mut();
|
||||
while let turso_core::StepResult::IO = stmt
|
||||
.borrow_mut()
|
||||
.step()
|
||||
.map_err(|e| PyErr::new::<OperationalError, _>(format!("Step error: {:?}", e)))?
|
||||
{
|
||||
self.conn
|
||||
.io
|
||||
.run_once()
|
||||
stmt.run_once()
|
||||
.map_err(|e| PyErr::new::<OperationalError, _>(format!("IO error: {:?}", e)))?;
|
||||
}
|
||||
}
|
||||
@@ -132,7 +130,7 @@ impl Cursor {
|
||||
return Ok(Some(py_row));
|
||||
}
|
||||
turso_core::StepResult::IO => {
|
||||
self.conn.io.run_once().map_err(|e| {
|
||||
stmt.run_once().map_err(|e| {
|
||||
PyErr::new::<OperationalError, _>(format!("IO error: {:?}", e))
|
||||
})?;
|
||||
}
|
||||
@@ -168,7 +166,7 @@ impl Cursor {
|
||||
results.push(py_row);
|
||||
}
|
||||
turso_core::StepResult::IO => {
|
||||
self.conn.io.run_once().map_err(|e| {
|
||||
stmt.run_once().map_err(|e| {
|
||||
PyErr::new::<OperationalError, _>(format!("IO error: {:?}", e))
|
||||
})?;
|
||||
}
|
||||
@@ -233,7 +231,7 @@ fn stmt_is_tx(sql: &str) -> bool {
|
||||
#[derive(Clone)]
|
||||
pub struct Connection {
|
||||
conn: Arc<turso_core::Connection>,
|
||||
io: Arc<dyn turso_core::IO>,
|
||||
_io: Arc<dyn turso_core::IO>,
|
||||
}
|
||||
|
||||
#[pymethods]
|
||||
@@ -308,7 +306,7 @@ impl Drop for Connection {
|
||||
#[pyfunction]
|
||||
pub fn connect(path: &str) -> Result<Connection> {
|
||||
match turso_core::Connection::from_uri(path, false, false) {
|
||||
Ok((io, conn)) => Ok(Connection { conn, io }),
|
||||
Ok((io, conn)) => Ok(Connection { conn, _io: io }),
|
||||
Err(e) => Err(PyErr::new::<ProgrammingError, _>(format!(
|
||||
"Failed to create connection: {:?}",
|
||||
e
|
||||
|
||||
Reference in New Issue
Block a user