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

Add begin_with methods to support database-specific transaction options #3614

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
chore: add tests of Error::InvalidSavePointStatement
bonsairobo committed Jan 26, 2025
commit 1d9afb32f817c028742e08588bcd7ab96c39b33f
14 changes: 14 additions & 0 deletions tests/mysql/error.rs
Original file line number Diff line number Diff line change
@@ -86,3 +86,17 @@ async fn it_fails_with_begin_failed() -> anyhow::Result<()> {

Ok(())
}

#[sqlx_macros::test]
async fn it_fails_with_invalid_save_point_statement() -> anyhow::Result<()> {
let mut conn = new::<MySql>().await?;
let mut txn = conn.begin().await?;
let txn_conn = sqlx::Acquire::acquire(&mut txn).await?;
let res = txn_conn.begin_with("BEGIN").await;

let err = res.unwrap_err();

assert!(matches!(err, Error::InvalidSavePointStatement), "{err}");

Ok(())
}
14 changes: 14 additions & 0 deletions tests/postgres/error.rs
Original file line number Diff line number Diff line change
@@ -86,3 +86,17 @@ async fn it_fails_with_begin_failed() -> anyhow::Result<()> {

Ok(())
}

#[sqlx_macros::test]
async fn it_fails_with_invalid_save_point_statement() -> anyhow::Result<()> {
let mut conn = new::<Postgres>().await?;
let mut txn = conn.begin().await?;
let txn_conn = sqlx::Acquire::acquire(&mut txn).await?;
let res = txn_conn.begin_with("BEGIN").await;

let err = res.unwrap_err();

assert!(matches!(err, Error::InvalidSavePointStatement), "{err}");

Ok(())
}
14 changes: 14 additions & 0 deletions tests/sqlite/error.rs
Original file line number Diff line number Diff line change
@@ -82,3 +82,17 @@ async fn it_fails_with_begin_failed() -> anyhow::Result<()> {

Ok(())
}

#[sqlx_macros::test]
async fn it_fails_with_invalid_save_point_statement() -> anyhow::Result<()> {
let mut conn = new::<Sqlite>().await?;
let mut txn = conn.begin().await?;
let txn_conn = sqlx::Acquire::acquire(&mut txn).await?;
let res = txn_conn.begin_with("BEGIN").await;

let err = res.unwrap_err();

assert!(matches!(err, Error::InvalidSavePointStatement), "{err}");

Ok(())
}