Skip to content

Commit

Permalink
make impl IntoFuture for Insertion generic over Database (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
nitn3lav authored Jan 8, 2024
1 parent 60928b6 commit f9e6853
Showing 1 changed file with 1 addition and 21 deletions.
22 changes: 1 addition & 21 deletions core/src/insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,7 @@ impl<'a, Acquire, Model, DB: sqlx::Database> Insertion<'a, Acquire, Model, DB> {
}
}


#[cfg(feature = "sqlite")]
impl<'a, Acquire, Model> std::future::IntoFuture for Insertion<'a, Acquire, Model, sqlx::sqlite::Sqlite>
where
Model: for<'r> sqlx::FromRow<'r, sqlx::sqlite::SqliteRow> + Send + Unpin,
Acquire: Send,
{
type Output = Result<Model>;
type IntoFuture = BoxFuture<'a, Self::Output>;

fn into_future(self) -> Self::IntoFuture {
let q = self.insert.to_sql(Dialect::Sqlite);
(self.closure)(self.acquire, self.model, q)
}
}

#[cfg(feature = "postgres")]
impl<'a, Acquire, Model> std::future::IntoFuture for Insertion<'a, Acquire, Model, sqlx::postgres::Postgres>
where
Model: for<'r> sqlx::FromRow<'r, sqlx::postgres::PgRow> + Send + Unpin
{
impl<'a, Acquire, Model: crate::model::Model<DB>, DB: sqlx::Database> std::future::IntoFuture for Insertion<'a, Acquire, Model, DB> {
type Output = Result<Model>;
type IntoFuture = BoxFuture<'a, Self::Output>;

Expand Down

0 comments on commit f9e6853

Please sign in to comment.