diff --git a/src/entity/active_model.rs b/src/entity/active_model.rs index c69e5b01..ab076bf0 100644 --- a/src/entity/active_model.rs +++ b/src/entity/active_model.rs @@ -1,6 +1,5 @@ use crate::{ - error::*, DatabaseConnection, DeleteResult, EntityTrait, Iterable, PrimaryKeyToColumn, - PrimaryKeyValue, Value, + error::*, DatabaseConnection, DeleteResult, EntityTrait, Iterable, PrimaryKeyToColumn, Value, }; use async_trait::async_trait; use std::fmt::Debug; @@ -70,8 +69,6 @@ pub trait ActiveModelTrait: Clone + Debug { async fn insert(self, db: &DatabaseConnection) -> Result where ::Model: IntoActiveModel, - <::Entity as EntityTrait>::PrimaryKey: - PrimaryKeyValue<::Entity>, { let am = self; let exec = ::insert(am).exec(db); @@ -96,8 +93,6 @@ pub trait ActiveModelTrait: Clone + Debug { where Self: ActiveModelBehavior, ::Model: IntoActiveModel, - <::Entity as EntityTrait>::PrimaryKey: - PrimaryKeyValue<::Entity>, { let mut am = self; am = ActiveModelBehavior::before_save(am); diff --git a/src/entity/base_entity.rs b/src/entity/base_entity.rs index 79caaf0b..d691fb3e 100644 --- a/src/entity/base_entity.rs +++ b/src/entity/base_entity.rs @@ -49,7 +49,9 @@ pub trait EntityTrait: EntityName { type Relation: RelationTrait; - type PrimaryKey: PrimaryKeyTrait + PrimaryKeyToColumn; + type PrimaryKey: PrimaryKeyTrait + + PrimaryKeyToColumn + + PrimaryKeyValue; fn belongs_to(related: R) -> RelationBuilder where @@ -299,8 +301,6 @@ pub trait EntityTrait: EntityName { fn insert(model: A) -> Insert where A: ActiveModelTrait, - <::Entity as EntityTrait>::PrimaryKey: - PrimaryKeyValue<::Entity>, { Insert::one(model) } @@ -354,8 +354,6 @@ pub trait EntityTrait: EntityName { where A: ActiveModelTrait, I: IntoIterator, - <::Entity as EntityTrait>::PrimaryKey: - PrimaryKeyValue<::Entity>, { Insert::many(models) } diff --git a/src/query/insert.rs b/src/query/insert.rs index 418d2b70..59c06b97 100644 --- a/src/query/insert.rs +++ b/src/query/insert.rs @@ -73,8 +73,6 @@ where pub fn one(m: M) -> Insert where M: IntoActiveModel, - <::Entity as EntityTrait>::PrimaryKey: - PrimaryKeyValue<::Entity>, { Self::new().add(m) } @@ -104,8 +102,6 @@ where where M: IntoActiveModel, I: IntoIterator, - <::Entity as EntityTrait>::PrimaryKey: - PrimaryKeyValue<::Entity>, { Self::new().add_many(models) } @@ -114,8 +110,6 @@ where pub fn add(mut self, m: M) -> Self where M: IntoActiveModel, - <::Entity as EntityTrait>::PrimaryKey: - PrimaryKeyValue<::Entity>, { let mut am: A = m.into_active_model(); self.primary_key = @@ -149,8 +143,6 @@ where where M: IntoActiveModel, I: IntoIterator, - <::Entity as EntityTrait>::PrimaryKey: - PrimaryKeyValue<::Entity>, { for model in models.into_iter() { self = self.add(model);