Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the trait bound &mut Transaction<'_, Sqlite>: Executor<'_> is not satisfied #2606

Closed
alimehasin opened this issue Jul 10, 2023 · 1 comment
Closed
Labels

Comments

@alimehasin
Copy link

Bug Description

After updating to v0.7.0 I got this error

error[E0277]: the trait bound `&mut Transaction<'_, Sqlite>: Executor<'_>` is not satisfied
   --> file.rs:584:18
    |
584 |         .execute(&mut tx)
    |          ------- ^^^^^^^ the trait `Executor<'_>` is not implemented for `&mut Transaction<'_, Sqlite>`
    |          |
    |          required by a bound introduced by this call
    |
    = help: the following other types implement trait `Executor<'c>`:
              <&'c mut AnyConnection as Executor<'c>>
              <&'c mut SqliteConnection as Executor<'c>>
              <&Pool<DB> as Executor<'p>>
note: required by a bound in `sqlx::query::Query::<'q, DB, A>::execute`
   --> /Users/alimehasin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sqlx-core-0.7.0/src/query.rs:151:12
    |
151 |         E: Executor<'c, Database = DB>,
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Query::<'q, DB, A>::execute`

Minimal Reproduction

let mut tx = pool.begin().await.unwrap();

sqlx::query(r#"query"#,)
.execute(&mut tx)
.await
.unwrap();

Info

  • SQLx version: 0.7.0
  • SQLx features enabled: "runtime-tokio-rustls", "sqlite", "chrono"
  • Database server and version: Sqlite)
  • Operating system: macOS
  • rustc --version: 1.170
@alimehasin alimehasin added the bug label Jul 10, 2023
@alimehasin
Copy link
Author

My bad, its mention in the CHANGELOG

The Executor impls for Transaction and PoolConnection have been deleted because they cannot exist in the new crate architecture without rewriting the Executor trait entirely.
To fix this breakage, simply add a dereference where an impl Executor is expected, as they both dereference to the inner connection type which will still implement it:
&mut transaction -> &mut *transaction
&mut connection -> &mut *connection

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant