Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make impl IntoFuture for Insertion generic over Database #42

Merged
merged 1 commit into from
Jan 8, 2024

Conversation

nitn3lav
Copy link
Contributor

@nitn3lav nitn3lav commented Jan 7, 2024

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 kurtbuilds merged commit f9e6853 into kurtbuilds:master Jan 8, 2024
1 check passed
@kurtbuilds
Copy link
Owner

Very nice. Thank you for adding this.

@nitn3lav nitn3lav deleted the generic-insert branch January 19, 2024 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants