Skip to content

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

Closed

Description

@alimehasin

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

Activity

  1. alimehasin commented on Jul 10, 2023

    @alimehasin
    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

  2. added a commit that references this issue on Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions