-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Labels
Description
I have found these related issues/pull requests
#3311
https://docs.rs/sqlx/latest/sqlx/struct.Transaction.html
Description
The second select in the code sample below returns the following error, even though that's how you're supposed to work with transactions (it does work if done like in the example linked above where everything is in the same function.
The workaround I've found is to call .as_mut()
, as the PR initially suggested. This can be seen as me overlooking that *
only gives me the Transaction and doesn't call deref on the transaction (see second working example), but in that case it might still be a good idea to put that into the documentation so others don't have to dig through issues+PRs here.
the trait `Executor<'_>` is not implemented for `&mut sqlx::Transaction<'_, Sqlite>`
Reproduction steps
async fn test(txn: &mut Transaction<'_, Sqlite>) {
// Works
sqlx::query("SELECT 1").execute(txn.as_mut()).await.unwrap();
// Doesn't work but is suggested by the docs
// Granted, in the docs `txn` is not behind a reference.
sqlx::query("SELECT 1").execute(&mut *txn).await.unwrap();
// Also works
sqlx::query("SELECT 1").execute(&mut **txn).await.unwrap();
}
SQLx version
0.8.6
Enabled SQLx features
"runtime-tokio", "sqlite"
Database server and version
Sqlite 3.50.4
Operating system
Linux
Rust version
rustc 1.90.0 (1159e78c4 2025-09-14)