Skip to content
Merged
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
14 changes: 9 additions & 5 deletions sqlx-core/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,19 @@ where
conn: impl Into<MaybePoolConnection<'c, DB>>,
statement: Option<SqlStr>,
) -> BoxFuture<'c, Result<Self, Error>> {
let mut conn = conn.into();
let conn = conn.into();

Box::pin(async move {
DB::TransactionManager::begin(&mut conn, statement).await?;

Ok(Self {
let mut tx = Self {
connection: conn,

// If the call to `begin` fails or doesn't complete we want to attempt a rollback in case the transaction was started.
open: true,
})
};

DB::TransactionManager::begin(&mut tx.connection, statement).await?;

Ok(tx)
})
}

Expand Down
Loading