Remove unnecessary trait bounds
This commit is contained in:
parent
3123a9d129
commit
5497810afb
@ -1,6 +1,5 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
error::*, DatabaseConnection, DeleteResult, EntityTrait, Iterable, PrimaryKeyToColumn,
|
error::*, DatabaseConnection, DeleteResult, EntityTrait, Iterable, PrimaryKeyToColumn, Value,
|
||||||
PrimaryKeyValue, Value,
|
|
||||||
};
|
};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
@ -70,8 +69,6 @@ pub trait ActiveModelTrait: Clone + Debug {
|
|||||||
async fn insert(self, db: &DatabaseConnection) -> Result<Self, DbErr>
|
async fn insert(self, db: &DatabaseConnection) -> Result<Self, DbErr>
|
||||||
where
|
where
|
||||||
<Self::Entity as EntityTrait>::Model: IntoActiveModel<Self>,
|
<Self::Entity as EntityTrait>::Model: IntoActiveModel<Self>,
|
||||||
<<Self as ActiveModelTrait>::Entity as EntityTrait>::PrimaryKey:
|
|
||||||
PrimaryKeyValue<<Self as ActiveModelTrait>::Entity>,
|
|
||||||
{
|
{
|
||||||
let am = self;
|
let am = self;
|
||||||
let exec = <Self::Entity as EntityTrait>::insert(am).exec(db);
|
let exec = <Self::Entity as EntityTrait>::insert(am).exec(db);
|
||||||
@ -96,8 +93,6 @@ pub trait ActiveModelTrait: Clone + Debug {
|
|||||||
where
|
where
|
||||||
Self: ActiveModelBehavior,
|
Self: ActiveModelBehavior,
|
||||||
<Self::Entity as EntityTrait>::Model: IntoActiveModel<Self>,
|
<Self::Entity as EntityTrait>::Model: IntoActiveModel<Self>,
|
||||||
<<Self as ActiveModelTrait>::Entity as EntityTrait>::PrimaryKey:
|
|
||||||
PrimaryKeyValue<<Self as ActiveModelTrait>::Entity>,
|
|
||||||
{
|
{
|
||||||
let mut am = self;
|
let mut am = self;
|
||||||
am = ActiveModelBehavior::before_save(am);
|
am = ActiveModelBehavior::before_save(am);
|
||||||
|
@ -49,7 +49,9 @@ pub trait EntityTrait: EntityName {
|
|||||||
|
|
||||||
type Relation: RelationTrait;
|
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>
|
fn belongs_to<R>(related: R) -> RelationBuilder<Self, R>
|
||||||
where
|
where
|
||||||
@ -299,8 +301,6 @@ pub trait EntityTrait: EntityName {
|
|||||||
fn insert<A>(model: A) -> Insert<A>
|
fn insert<A>(model: A) -> Insert<A>
|
||||||
where
|
where
|
||||||
A: ActiveModelTrait<Entity = Self>,
|
A: ActiveModelTrait<Entity = Self>,
|
||||||
<<A as ActiveModelTrait>::Entity as EntityTrait>::PrimaryKey:
|
|
||||||
PrimaryKeyValue<<A as ActiveModelTrait>::Entity>,
|
|
||||||
{
|
{
|
||||||
Insert::one(model)
|
Insert::one(model)
|
||||||
}
|
}
|
||||||
@ -354,8 +354,6 @@ pub trait EntityTrait: EntityName {
|
|||||||
where
|
where
|
||||||
A: ActiveModelTrait<Entity = Self>,
|
A: ActiveModelTrait<Entity = Self>,
|
||||||
I: IntoIterator<Item = A>,
|
I: IntoIterator<Item = A>,
|
||||||
<<A as ActiveModelTrait>::Entity as EntityTrait>::PrimaryKey:
|
|
||||||
PrimaryKeyValue<<A as ActiveModelTrait>::Entity>,
|
|
||||||
{
|
{
|
||||||
Insert::many(models)
|
Insert::many(models)
|
||||||
}
|
}
|
||||||
|
@ -73,8 +73,6 @@ where
|
|||||||
pub fn one<M>(m: M) -> Insert<A>
|
pub fn one<M>(m: M) -> Insert<A>
|
||||||
where
|
where
|
||||||
M: IntoActiveModel<A>,
|
M: IntoActiveModel<A>,
|
||||||
<<A as ActiveModelTrait>::Entity as EntityTrait>::PrimaryKey:
|
|
||||||
PrimaryKeyValue<<A as ActiveModelTrait>::Entity>,
|
|
||||||
{
|
{
|
||||||
Self::new().add(m)
|
Self::new().add(m)
|
||||||
}
|
}
|
||||||
@ -104,8 +102,6 @@ where
|
|||||||
where
|
where
|
||||||
M: IntoActiveModel<A>,
|
M: IntoActiveModel<A>,
|
||||||
I: IntoIterator<Item = M>,
|
I: IntoIterator<Item = M>,
|
||||||
<<A as ActiveModelTrait>::Entity as EntityTrait>::PrimaryKey:
|
|
||||||
PrimaryKeyValue<<A as ActiveModelTrait>::Entity>,
|
|
||||||
{
|
{
|
||||||
Self::new().add_many(models)
|
Self::new().add_many(models)
|
||||||
}
|
}
|
||||||
@ -114,8 +110,6 @@ where
|
|||||||
pub fn add<M>(mut self, m: M) -> Self
|
pub fn add<M>(mut self, m: M) -> Self
|
||||||
where
|
where
|
||||||
M: IntoActiveModel<A>,
|
M: IntoActiveModel<A>,
|
||||||
<<A as ActiveModelTrait>::Entity as EntityTrait>::PrimaryKey:
|
|
||||||
PrimaryKeyValue<<A as ActiveModelTrait>::Entity>,
|
|
||||||
{
|
{
|
||||||
let mut am: A = m.into_active_model();
|
let mut am: A = m.into_active_model();
|
||||||
self.primary_key =
|
self.primary_key =
|
||||||
@ -149,8 +143,6 @@ where
|
|||||||
where
|
where
|
||||||
M: IntoActiveModel<A>,
|
M: IntoActiveModel<A>,
|
||||||
I: IntoIterator<Item = M>,
|
I: IntoIterator<Item = M>,
|
||||||
<<A as ActiveModelTrait>::Entity as EntityTrait>::PrimaryKey:
|
|
||||||
PrimaryKeyValue<<A as ActiveModelTrait>::Entity>,
|
|
||||||
{
|
{
|
||||||
for model in models.into_iter() {
|
for model in models.into_iter() {
|
||||||
self = self.add(model);
|
self = self.add(model);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user