mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
fix(backend): rollback write transaction on error in SQL query block
Use explicit except/else instead of finally to ensure write transactions are rolled back when an exception occurs, rather than committed.
This commit is contained in:
@@ -276,7 +276,10 @@ def _run_in_transaction(
|
||||
{col: _serialize_value(val) for col, val in zip(columns, row)}
|
||||
for row in rows
|
||||
]
|
||||
finally:
|
||||
except Exception:
|
||||
conn.execute(text("ROLLBACK"))
|
||||
raise
|
||||
else:
|
||||
conn.execute(text("ROLLBACK" if read_only else "COMMIT"))
|
||||
return results, columns, affected
|
||||
|
||||
|
||||
Reference in New Issue
Block a user