1use super::Dtid;
2
3impl From<Dtid> for sea_orm::Value {
4 fn from(value: Dtid) -> Self {
5 sea_orm::sea_query::Value::Unsigned(Some(value.into()))
6 }
7}
8
9impl sea_orm::TryGetable for Dtid {
10 fn try_get_by<I: sea_orm::ColIdx>(
11 res: &sea_orm::QueryResult,
12 index: I,
13 ) -> Result<Self, sea_orm::TryGetError> {
14 match <u32 as sea_orm::TryGetable>::try_get_by(res, index) {
15 Ok(x) => Dtid::try_from(x).map_err(|e| {
16 sea_orm::TryGetError::DbErr(sea_orm::DbErr::TryIntoErr {
17 from: stringify!(u32),
18 into: stringify!(mtid::Dtid),
19 source: Box::new(e),
20 })
21 }),
22 Err(x) => Err(x),
23 }
24 }
25}
26
27impl sea_orm::sea_query::ValueType for Dtid {
28 fn try_from(v: sea_orm::Value) -> Result<Self, sea_orm::sea_query::ValueTypeErr> {
29 <u32 as sea_orm::sea_query::ValueType>::try_from(v).map(|x| {
30 <Dtid as TryFrom<u32>>::try_from(x).map_err(|_| sea_orm::sea_query::ValueTypeErr)
31 })?
32 }
33 fn type_name() -> String {
34 stringify!(Dtid).to_owned()
35 }
36 fn array_type() -> sea_orm::sea_query::ArrayType {
37 sea_orm::sea_query::ArrayType::Unsigned
38 }
39 fn column_type() -> sea_orm::ColumnType {
40 sea_orm::sea_query::ColumnType::Unsigned
41 }
42}
43
44impl sea_orm::sea_query::Nullable for Dtid {
45 fn null() -> sea_orm::Value {
46 <u32 as sea_orm::sea_query::Nullable>::null()
47 }
48}