kurtbuilds / ormlite

An ORM in Rust for developers that love SQL.
https://crates.io/crates/ormlite
MIT License
216 stars 11 forks source link

make `impl IntoFuture for Insertion` generic over Database #42

Closed nitn3lav closed 6 months ago

nitn3lav commented 6 months ago

This enables writing code like this:

async fn hi<D: Model<Postgres> + Send>(data: D, conn: &ormlite::Pool<Postgres>) {
    let _ = data.insert(conn).await.unwrap();
}

Previously, this would have required an ugly where clause:

async fn hi<D: Model<Postgres> + Send>(data: D, conn: &ormlite::Pool<Postgres>)
where
    for<'a> ormlite_core::insert::Insertion<'a, &'a ormlite::Pool<Database>, D, Database>: IntoFuture,
{
    let _ = data.insert(conn).await;
}
kurtbuilds commented 6 months ago

Very nice. Thank you for adding this.