(client: &'a mut Client)
| 357 | |
| 358 | impl<'a> Transaction<'a> { |
| 359 | async fn new(client: &'a mut Client) -> Result<Self, SqlServerError> { |
| 360 | // Construct the guard *before* awaiting BEGIN to avoid a potential race where |
| 361 | // transaction is started on remote, but the transaction is cancelled before returning. |
| 362 | let tx = Transaction { |
| 363 | client, |
| 364 | closed: false, |
| 365 | }; |
| 366 | let results = tx |
| 367 | .client |
| 368 | .simple_query("BEGIN TRANSACTION") |
| 369 | .await |
| 370 | .context("begin")?; |
| 371 | if !results.is_empty() { |
| 372 | Err(SqlServerError::InvariantViolated(format!( |
| 373 | "expected empty result from BEGIN TRANSACTION. Got: {results:?}" |
| 374 | ))) |
| 375 | } else { |
| 376 | Ok(tx) |
| 377 | } |
| 378 | } |
| 379 | |
| 380 | /// Creates a savepoint via `SAVE TRANSACTION` with the provided name. |
| 381 | /// Creating a savepoint forces a write to the transaction log, which will associate an |
nothing calls this directly
no test coverage detected