mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-18 17:14:20 +01:00
Do not rollback in TxError
Fixes #2153. Not so sure if SQLite doesn't rollback in more cases, we should definitively check this out.
This commit is contained in:
26
tests/integration/query_processing/test_transactions.rs
Normal file
26
tests/integration/query_processing/test_transactions.rs
Normal file
@@ -0,0 +1,26 @@
|
||||
use turso_core::{LimboError, Result, StepResult, Value};
|
||||
|
||||
use crate::common::TempDatabase;
|
||||
|
||||
#[test]
|
||||
fn test_txn_error_doesnt_rollback_txn() -> Result<()> {
|
||||
let tmp_db = TempDatabase::new_with_rusqlite("create table t(x);", false);
|
||||
let conn = tmp_db.connect_limbo();
|
||||
|
||||
conn.execute("begin")?;
|
||||
conn.execute("insert into t values (1)")?;
|
||||
// should fail
|
||||
assert!(conn
|
||||
.execute("begin")
|
||||
.inspect_err(|e| assert!(matches!(e, LimboError::TxError(_))))
|
||||
.is_err());
|
||||
conn.execute("insert into t values (1)")?;
|
||||
conn.execute("commit")?;
|
||||
let mut stmt = conn.query("select sum(x) from t")?.unwrap();
|
||||
if let StepResult::Row = stmt.step()? {
|
||||
let row = stmt.row().unwrap();
|
||||
assert_eq!(*row.get::<&Value>(0).unwrap(), Value::Integer(2));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user