| 267 | |
| 268 | #[instrument(level = "trace")] |
| 269 | async fn begin_with_config( |
| 270 | &self, |
| 271 | _isolation_level: Option<IsolationLevel>, |
| 272 | _access_mode: Option<AccessMode>, |
| 273 | ) -> Result<DatabaseTransaction, DbErr> { |
| 274 | match self { |
| 275 | #[cfg(feature = "sqlx-mysql")] |
| 276 | DatabaseConnection::SqlxMySqlPoolConnection(conn) => { |
| 277 | conn.begin(_isolation_level, _access_mode).await |
| 278 | } |
| 279 | #[cfg(feature = "sqlx-postgres")] |
| 280 | DatabaseConnection::SqlxPostgresPoolConnection(conn) => { |
| 281 | conn.begin(_isolation_level, _access_mode).await |
| 282 | } |
| 283 | #[cfg(feature = "sqlx-sqlite")] |
| 284 | DatabaseConnection::SqlxSqlitePoolConnection(conn) => { |
| 285 | conn.begin(_isolation_level, _access_mode).await |
| 286 | } |
| 287 | #[cfg(feature = "mock")] |
| 288 | DatabaseConnection::MockDatabaseConnection(conn) => { |
| 289 | DatabaseTransaction::new_mock(Arc::clone(conn), None).await |
| 290 | } |
| 291 | #[cfg(feature = "proxy")] |
| 292 | DatabaseConnection::ProxyDatabaseConnection(conn) => { |
| 293 | DatabaseTransaction::new_proxy(conn.clone(), None).await |
| 294 | } |
| 295 | DatabaseConnection::Disconnected => Err(conn_err("Disconnected")), |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | /// Execute the function inside a transaction. |
| 300 | /// If the function returns an error, the transaction will be rolled back. If it does not return an error, the transaction will be committed. |