Open
Description
Bug Description
Edit: the one SQLite example was not updated to dereference PoolConnection
, leading to this error. It should just be updated to use .execute(&mut *conn)
.
The execute
/fetch_one
/fetch_all
etc. functions throw compile-time errors when using PoolConnection
on main
. Edit: they just need to be dereferenced.
I'm guessing this is known, and is why the examples were removed from the workspace Cargo.toml
for the 0.7.0-alpha.1
merge to main
.
Minimal Reproduction
The SQLite TODOs example in the repository.
let mut conn: PoolConnection<Sqlite> = pool.acquire().await?;
// Insert the task, then obtain the ID of this row
let id = sqlx::query!(
r#"
INSERT INTO todos ( description )
VALUES ( ?1 )
"#,
description
)
.execute(&mut conn)
.await?
.last_insert_rowid();
Error:
error[E0277]: the trait bound `&mut sqlx::pool::PoolConnection<Sqlite>: Executor<'_>` is not satisfied
--> examples/sqlite/todos/src/main.rs:60:14
|
60 | .execute(&mut conn)
| ------- ^^^^^^^^^ the trait `Executor<'_>` is not implemented for `&mut sqlx::pool::PoolConnection<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 `Query::<'q, DB, A>::execute`
--> /sqlx/sqlx-core/src/query.rs:151:12
|
151 | E: Executor<'c, Database = DB>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Query::<'q, DB, A>::execute`
Info
- SQLx version: 0.7.0-alpha.1 (
main
branch, commit f05c884) - SQLx features enabled:
["sqlite", "runtime-tokio-native-tls"]
- Database server and version: SQLite
- Operating system: MacOS
rustc --version
: rustc 1.67.1 (d5a82bbd2 2023-02-07)