postgresqlrustsqlxrust-sqlxsea-orm

SeaOrm connection for Sqlx


I am using a SeaOrm v1.0.0 connection with Sqlx v0.8.0. This was working just fine until I upgraded to the latest version.

Now I get error:

error[E0277]: the trait bound `&sea_orm::sqlx::Pool<sea_orm::sqlx::Postgres>: sqlx::Executor<'_>` is not satisfied
  --> src/r/a/a/search_gtin.rs:84:20
   |
84 |             .fetch(&conn);
   |              ----- ^^^^^ the trait `sqlx::Executor<'_>` is not implemented for `&sea_orm::sqlx::Pool<sea_orm::sqlx::Postgres>`
   |              |
   |              required by a bound introduced by this call
   |
   = help: the following other types implement trait `sqlx::Executor<'c>`:
             <&'c mut sqlx::PgConnection as sqlx::Executor<'c>>
             <&'c mut sqlx::sqlx_postgres::PgListener as sqlx::Executor<'c>>
             <&sqlx::Pool<DB> as sqlx::Executor<'p>>
note: required by a bound in `sqlx::query::QueryAs::<'q, DB, O, A>::fetch`
  --> /Users/x/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sqlx-core-0.8.0/src/query_as.rs:92:17
   |
89 |     pub fn fetch<'e, 'c: 'e, E>(self, executor: E) -> BoxStream<'e, Result<O, Error>>
   |            ----- required by a bound in this associated function
...
92 |         E: 'e + Executor<'c, Database = DB>,
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `QueryAs::<'q, DB, O, A>::fetch`

For:

let conn = state.connection.get_postgres_connection_pool().clone();

let mut stream = query_as::<_, SearchGtinData>(
    r#"SELECT 1
    "#,
)
    .bind(gtin)
    .fetch(&conn);

I'm not sure how to fix it. Any suggestions?


Solution

  • Use SQLx 0.7.0. SeaORM 1.0.0 only integrates with that version as indicated by its dependencies.