Remove unnecessary trait bounds

This commit is contained in:
Billy Chan 2021-09-30 11:49:27 +08:00
parent 3123a9d129
commit 5497810afb
No known key found for this signature in database
GPG Key ID: A2D690CAC7DF3CC7
3 changed files with 4 additions and 19 deletions

View File

@ -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<Self, DbErr>
where
<Self::Entity as EntityTrait>::Model: IntoActiveModel<Self>,
<<Self as ActiveModelTrait>::Entity as EntityTrait>::PrimaryKey:
PrimaryKeyValue<<Self as ActiveModelTrait>::Entity>,
{
let am = self;
let exec = <Self::Entity as EntityTrait>::insert(am).exec(db);
@ -96,8 +93,6 @@ pub trait ActiveModelTrait: Clone + Debug {
where
Self: ActiveModelBehavior,
<Self::Entity as EntityTrait>::Model: IntoActiveModel<Self>,
<<Self as ActiveModelTrait>::Entity as EntityTrait>::PrimaryKey:
PrimaryKeyValue<<Self as ActiveModelTrait>::Entity>,
{
let mut am = self;
am = ActiveModelBehavior::before_save(am);

View File

@ -49,7 +49,9 @@ pub trait EntityTrait: EntityName {
type Relation: RelationTrait;
type PrimaryKey: PrimaryKeyTrait + PrimaryKeyToColumn<Column = Self::Column>;
type PrimaryKey: PrimaryKeyTrait
+ PrimaryKeyToColumn<Column = Self::Column>
+ PrimaryKeyValue<Self>;
fn belongs_to<R>(related: R) -> RelationBuilder<Self, R>
where
@ -299,8 +301,6 @@ pub trait EntityTrait: EntityName {
fn insert<A>(model: A) -> Insert<A>
where
A: ActiveModelTrait<Entity = Self>,
<<A as ActiveModelTrait>::Entity as EntityTrait>::PrimaryKey:
PrimaryKeyValue<<A as ActiveModelTrait>::Entity>,
{
Insert::one(model)
}
@ -354,8 +354,6 @@ pub trait EntityTrait: EntityName {
where
A: ActiveModelTrait<Entity = Self>,
I: IntoIterator<Item = A>,
<<A as ActiveModelTrait>::Entity as EntityTrait>::PrimaryKey:
PrimaryKeyValue<<A as ActiveModelTrait>::Entity>,
{
Insert::many(models)
}

View File

@ -73,8 +73,6 @@ where
pub fn one<M>(m: M) -> Insert<A>
where
M: IntoActiveModel<A>,
<<A as ActiveModelTrait>::Entity as EntityTrait>::PrimaryKey:
PrimaryKeyValue<<A as ActiveModelTrait>::Entity>,
{
Self::new().add(m)
}
@ -104,8 +102,6 @@ where
where
M: IntoActiveModel<A>,
I: IntoIterator<Item = M>,
<<A as ActiveModelTrait>::Entity as EntityTrait>::PrimaryKey:
PrimaryKeyValue<<A as ActiveModelTrait>::Entity>,
{
Self::new().add_many(models)
}
@ -114,8 +110,6 @@ where
pub fn add<M>(mut self, m: M) -> Self
where
M: IntoActiveModel<A>,
<<A as ActiveModelTrait>::Entity as EntityTrait>::PrimaryKey:
PrimaryKeyValue<<A as ActiveModelTrait>::Entity>,
{
let mut am: A = m.into_active_model();
self.primary_key =
@ -149,8 +143,6 @@ where
where
M: IntoActiveModel<A>,
I: IntoIterator<Item = M>,
<<A as ActiveModelTrait>::Entity as EntityTrait>::PrimaryKey:
PrimaryKeyValue<<A as ActiveModelTrait>::Entity>,
{
for model in models.into_iter() {
self = self.add(model);