You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I want to make a generic create sql call, I find it won't compile as expected.
pubasyncfnupsert_download_event<'q,'e,E>(executor:E,uuid:String,status:String,) -> Result<(), sqlx::Error>whereE:Executor<'e>,E::Database: sqlx::Database,DateTime<Utc>: sqlx::Type<E::Database> + sqlx::Encode<'q,E::Database>,String: sqlx::Type<E::Database> + sqlx::Encode<'q,E::Database>{let query = sqlx::query(r#" INSERT INTO m3u8_download_event ( created_at, updated_at, uuid, status ) VALUES ($1, $2, $3, $4) ON CONFLICT (uuid) DO UPDATE SET updated_at = EXCLUDED.updated_at, status = EXCLUDED.status "#,).bind(Utc::now()).bind(Utc::now()).bind(uuid).bind(status);
query.execute(executor).await?;Ok(())}
It will got
error[E0599]: the method `execute` exists for struct `Query<'_, <E as Executor<'e>>::Database, ...>`, but its trait bounds were not satisfied
--> src/a.rs:232:11
|
232 | query.execute(executor).await?;
| ^^^^^^^ method cannot be called on `Query<'_, <E as Executor<'e>>::Database, ...>` due to unsatisfied trait bounds
|
= note: the following trait bounds were not satisfied:
`<<E as Executor<'e>>::Database as sqlx::Database>::Arguments<'_>: IntoArguments<'_, <E as Executor<'e>>::Database>`
It is too strange that <<E as Executor<'e>>::Database as sqlx::Database>::Arguments<'_> doesn't impl IntoArguments<'_, <E as Executor<'e>>::Database>. (It's already Arguments)
I have found these related issues/pull requests
relates to #3833
Description
When I want to make a generic create sql call, I find it won't compile as expected.
It will got
It is too strange that
<<E as Executor<'e>>::Database as sqlx::Database>::Arguments<'_>
doesn't implIntoArguments<'_, <E as Executor<'e>>::Database>
. (It's alreadyArguments
)I found that others have also encountered the same/similar issue in discord channel
https://discordapp.com/channels/665528275556106240/665528275556106243/1363047542996205579.
Prefered solution
like #3833
To avoid introducing breaking changes and without modifying the implementation of
Query
, we can add an implementation forArguments
.Is this a breaking change? Why or why not?
struct which impl both Arguments and IntoArguments will conflict now.
The text was updated successfully, but these errors were encountered: