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.