Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
aqrln committed Nov 22, 2023
1 parent fc5d993 commit 3534f22
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ mod prisma_7010;
mod prisma_7072;
mod prisma_7434;
mod prisma_8265;
mod prisma_engines_4286;
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use query_engine_tests::*;

#[test_suite(schema(generic), only(Sqlite))]
mod sqlite {
#[connector_test]
async fn close_tx_on_error(runner: Runner) -> TestResult<()> {
// Try to open a transaction with unsupported isolation error in SQLite.
let result = runner.start_tx(2000, 5000, Some("ReadUncommitted".to_owned())).await;
assert!(result.is_err());

// Without the changes from https://github.com/prisma/prisma-engines/pull/4286 or
// https://github.com/prisma/prisma-engines/pull/4489 this second `start_tx` call will
// either hang infinitely with libSQL driver adapter, or fail with a "cannot start a
// transaction within a transaction" error.
// A more future proof way to check this would be to make both transactions EXCLUSIVE or
// IMMEDIATE if we had control over SQLite transaction type here, as that would not rely on
// both transactions using the same connection if we were to pool multiple SQLite
// connections in the future.
let tx = runner.start_tx(2000, 5000, None).await?;
runner.rollback_tx(tx).await?.unwrap();

Ok(())
}
}

0 comments on commit 3534f22

Please sign in to comment.