Implements fmt::Display
for ActiveEnum
(#986)
Co-authored-by: Chris Tsang <chris.2y3@outlook.com>
This commit is contained in:
parent
dd92a6860b
commit
b91ca2b778
@ -353,6 +353,14 @@ impl ActiveEnum {
|
||||
<<Self as sea_orm::ActiveEnum>::Value as sea_orm::sea_query::Nullable>::null()
|
||||
}
|
||||
}
|
||||
|
||||
#[automatically_derived]
|
||||
impl std::fmt::Display for #ident {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let v: sea_orm::sea_query::Value = self.to_value().into();
|
||||
write!(f, "{}", v)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -241,6 +241,9 @@ mod tests {
|
||||
DeriveCategory::name().to_string()
|
||||
);
|
||||
assert_eq!(Category::values(), DeriveCategory::values());
|
||||
|
||||
assert_eq!(format!("{}", DeriveCategory::Big), "'B'");
|
||||
assert_eq!(format!("{}", DeriveCategory::Small), "'S'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -295,6 +298,10 @@ mod tests {
|
||||
);
|
||||
|
||||
assert_eq!($ident::db_type(), ColumnType::$col_def.def());
|
||||
|
||||
assert_eq!(format!("{}", $ident::Big), "1");
|
||||
assert_eq!(format!("{}", $ident::Small), "0");
|
||||
assert_eq!(format!("{}", $ident::Negative), "-10");
|
||||
};
|
||||
}
|
||||
|
||||
@ -356,6 +363,9 @@ mod tests {
|
||||
);
|
||||
|
||||
assert_eq!($ident::db_type(), ColumnType::$col_def.def());
|
||||
|
||||
assert_eq!(format!("{}", $ident::Big), "1");
|
||||
assert_eq!(format!("{}", $ident::Small), "0");
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user