Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

429
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!