From 78c153060185b790fd539ba87cba4284ec43f68b Mon Sep 17 00:00:00 2001 From: dull b Date: Mon, 24 Jul 2023 18:43:18 +0000 Subject: [PATCH] Revert "Insert trait" This reverts commit 9d780c24035d3a9fb12968d3009a28724046dc3a. --- crates/db_schema/src/traits.rs | 38 ++++++++-------------------------- 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/crates/db_schema/src/traits.rs b/crates/db_schema/src/traits.rs index 1c17fbdd7..7cafaef7f 100644 --- a/crates/db_schema/src/traits.rs +++ b/crates/db_schema/src/traits.rs @@ -7,15 +7,13 @@ use diesel::{ dsl, expression::{AsExpression, TypedExpressionType}, expression_methods::ExpressionMethods, - insert_into, - query_builder::{DeleteStatement, InsertStatement, IntoUpdateTarget}, + query_builder::{DeleteStatement, IntoUpdateTarget}, query_dsl::methods::{FindDsl, LimitDsl}, result::Error, sql_types::SqlType, AsChangeset, Expression, Insertable, - QuerySource, Table, }; use diesel_async::{ @@ -28,28 +26,6 @@ use std::hash::Hash; /// Returned by `diesel::delete` pub type Delete = DeleteStatement<::Table, ::WhereClause>; -pub trait Insert<'a, Tb, U> -where - Self: 'a, - &'a Self: Insertable, - InsertStatement>::Values>: - LoadQuery<'a, AsyncPgConnection, U> + 'a + Send, - <&'a Self as Insertable>::Values: 'a, - Tb: QuerySource, -{ -} - -impl<'a, Tb, U, T> Insert<'a, Tb, U> for T -where - Self: 'a, - &'a Self: Insertable, - InsertStatement>::Values>: - LoadQuery<'a, AsyncPgConnection, U> + 'a + Send, - <&'a Self as Insertable>::Values: 'a, - Tb: QuerySource, -{ -} - /*Self: Send + 'static + Sized + HasTable, Self::Table: FindDsl + Send + Sized + 'static, @@ -70,19 +46,23 @@ where SqlType + TypedExpressionType, for<'a> Delete>: ExecuteDsl + 'a + Send, { - type InsertForm: for<'a> Insert<'a, Self::Table, Self>; + /*for<'a> &'a Self::InsertForm: Insertable, + for<'a> InsertStatement>::Values>: + LoadQuery<'a, AsyncPgConnection, Self> + 'a, + for<'a> <&'a Self::InsertForm as Insertable>::Values: 'a,*/ + type InsertForm; type UpdateForm; type IdType: Hash + Eq + Sized + Send + AsExpression<<::PrimaryKey as Expression>::SqlType>; - - async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result { + async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result; + /*{ let query = insert_into(Self::table()).values(form); let conn = &mut *get_conn(pool).await?; query.get_result::(conn).await - } + }*/ async fn read(pool: &mut DbPool<'_>, id: Self::IdType) -> Result { let query = Self::table().find(id); let conn = &mut *get_conn(pool).await?;