From 2b4d7ef300b787f8efabcc3bf2e0ee1da6110c0b Mon Sep 17 00:00:00 2001 From: Oscar Beaumont Date: Mon, 10 Nov 2025 12:05:35 +0800 Subject: [PATCH] add `Transaction::commit` + `Transaction::rollback` --- src/transaction.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/transaction.rs b/src/transaction.rs index abc71ea..253f4c5 100644 --- a/src/transaction.rs +++ b/src/transaction.rs @@ -1,4 +1,5 @@ use futures::{StreamExt, TryStreamExt}; +use sqlx::Error; use tracing::Instrument; impl<'c, DB> crate::Transaction<'c, DB> @@ -15,6 +16,16 @@ where attributes: self.attributes.clone(), } } + + /// Commits this transaction or savepoint. + pub async fn commit(self) -> Result<(), Error> { + self.inner.commit().await + } + + /// Aborts this transaction or savepoint. + pub async fn rollback(self) -> Result<(), Error> { + self.inner.rollback().await + } } /// Implements `sqlx::Executor` for a mutable reference to a tracing-instrumented transaction.