Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

434
Vistas
Rust sqlx: there is no query finalizers

The issue is when I type code like this.

let data = sqlx::query("SELECT id, name FROM test")
        .fetch_all(&pool)
        .await;

I get an no method named `fetch_all` found for struct `sqlx_core::query::Query<'_, _>` in the current scope error. Following official getting started readme. This is also applicable to the query_as method. I suspect that for some reason the compiler doesn't "see" sqlx::Query trait methods, but I don't know how to bring them in scope.

Although when I use macro sqlx::query!, .fetch_all does exist.

Also, there is an inconvenience that rust-analyzer LSP tells me that the type of the data variable is std::result::Result<[type error], [type error]>, which removes any possibility of using autocompletion and type checking, other than running (notoriously slow) rust compiler.

P.S. I use PostgreSQL as a database solution, if that may help.

P.S.S. env variable DATABASE_URL is set at the compile-time and is correct, so macros do all of the compile-time validation stuff.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Browsing docs.rs a bit, I found that type sqlx::Query does not even have finalizers other than fetch. As for sqlx::query_as, the trait I was looking for was called PgQueryAs, which actually contains fetch_all, fetch_optional, fetch_one, etc. And adding use sqlx::postgress::PgQueryAs fixed the problem for me.

Despite that, I still don't know a solution for evaluating macros to get decent types in my IDE.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda