Merge FromQueryResultExt into FromQueryResult
This commit is contained in:
parent
94b5fbf413
commit
2e1371537a
@ -28,20 +28,13 @@ pub trait ModelTrait: Clone + Send + Debug {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait FromQueryResult {
|
pub trait FromQueryResult: Sized {
|
||||||
fn from_query_result(res: &QueryResult, pre: &str) -> Result<Self, DbErr>
|
fn from_query_result(res: &QueryResult, pre: &str) -> Result<Self, DbErr>;
|
||||||
where
|
|
||||||
Self: Sized;
|
|
||||||
|
|
||||||
fn from_query_result_optional(res: &QueryResult, pre: &str) -> Result<Option<Self>, DbErr>
|
fn from_query_result_optional(res: &QueryResult, pre: &str) -> Result<Option<Self>, DbErr> {
|
||||||
where
|
|
||||||
Self: Sized,
|
|
||||||
{
|
|
||||||
Ok(Self::from_query_result(res, pre).ok())
|
Ok(Self::from_query_result(res, pre).ok())
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
pub trait FromQueryResultExt: FromQueryResult + Sized {
|
|
||||||
/// ```
|
/// ```
|
||||||
/// # #[cfg(feature = "mock")]
|
/// # #[cfg(feature = "mock")]
|
||||||
/// # use sea_orm::{error::*, tests_cfg::*, MockDatabase, Transaction, DbBackend};
|
/// # use sea_orm::{error::*, tests_cfg::*, MockDatabase, Transaction, DbBackend};
|
||||||
@ -107,5 +100,3 @@ pub trait FromQueryResultExt: FromQueryResult + Sized {
|
|||||||
SelectorRaw::<SelectModel<Self>>::from_statement(stmt)
|
SelectorRaw::<SelectModel<Self>>::from_statement(stmt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: FromQueryResult> FromQueryResultExt for T {}
|
|
||||||
|
@ -2,9 +2,8 @@ pub use crate::{
|
|||||||
error::*, ActiveModelBehavior, ActiveModelTrait, ColumnDef, ColumnTrait, ColumnType,
|
error::*, ActiveModelBehavior, ActiveModelTrait, ColumnDef, ColumnTrait, ColumnType,
|
||||||
DeriveActiveModel, DeriveActiveModelBehavior, DeriveColumn, DeriveCustomColumn, DeriveEntity,
|
DeriveActiveModel, DeriveActiveModelBehavior, DeriveColumn, DeriveCustomColumn, DeriveEntity,
|
||||||
DeriveEntityModel, DeriveModel, DerivePrimaryKey, DeriveRelation, EntityName, EntityTrait,
|
DeriveEntityModel, DeriveModel, DerivePrimaryKey, DeriveRelation, EntityName, EntityTrait,
|
||||||
EnumIter, ForeignKeyAction, FromQueryResultExt, Iden, IdenStatic, Linked, ModelTrait,
|
EnumIter, ForeignKeyAction, Iden, IdenStatic, Linked, ModelTrait, PrimaryKeyToColumn,
|
||||||
PrimaryKeyToColumn, PrimaryKeyTrait, QueryFilter, QueryResult, Related, RelationDef,
|
PrimaryKeyTrait, QueryFilter, QueryResult, Related, RelationDef, RelationTrait, Select, Value,
|
||||||
RelationTrait, Select, Value,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "with-json")]
|
#[cfg(feature = "with-json")]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user