Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(driver-adapters): support Transaction Isolation Levels in PlanetScale #4966

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -598,9 +598,7 @@ mod itx_isolation {
Ok(())
}

// On PlanetScale, this fails with:
// `InteractiveTransactionError("Error in connector: Error querying the database: Server error: `ERROR 25001 (1568): Transaction characteristics can't be changed while a transaction is in progress'")`
#[connector_test(exclude(MongoDb, Vitess("planetscale.js", "planetscale.js.wasm"), Sqlite("cfd1")))]
#[connector_test(exclude(MongoDb, Sqlite("cfd1")))]
async fn casing_doesnt_matter(mut runner: Runner) -> TestResult<()> {
let tx_id = runner.start_tx(5000, 5000, Some("sErIaLiZaBlE".to_owned())).await?;
runner.set_active_tx(tx_id.clone());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@ mod transactional {
Ok(())
}

// On PlanetScale, this fails with:
// "Error in connector: Error querying the database: Server error: `ERROR 25001 (1568): Transaction characteristics can't be changed while a transaction is in progress'""
#[connector_test(exclude(MongoDb, Vitess("planetscale.js", "planetscale.js.wasm")))]
#[connector_test(exclude(MongoDb))]
async fn valid_isolation_level(runner: Runner) -> TestResult<()> {
let queries = vec![r#"mutation { createOneModelB(data: { id: 1 }) { id }}"#.to_string()];

Expand Down
8 changes: 4 additions & 4 deletions query-engine/driver-adapters/src/queryable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,16 +294,16 @@ impl TransactionCapable for JsQueryable {
&'a self,
isolation: Option<IsolationLevel>,
) -> quaint::Result<Box<dyn Transaction + 'a>> {
let tx = self.driver_proxy.start_transaction().await?;

let isolation_first = tx.requires_isolation_first();
let isolation_first = self.requires_isolation_first();

if isolation_first {
if let Some(isolation) = isolation {
tx.set_tx_isolation_level(isolation).await?;
self.set_tx_isolation_level(isolation).await?;
}
}

let tx = self.driver_proxy.start_transaction().await?;

let begin_stmt = tx.begin_statement();

let tx_opts = tx.options();
Expand Down
Loading