pub struct CustomOption<T>(pub Option<T>);
impl<T> From<Option<T>> for CustomOption<T>
where
T: Into<sea_query::SimpleExpr>,
{
fn from(value: Option<T>) -> Self {
Self(value)
}
}
impl<T> CustomOption<T>
where
T: Into<sea_query::SimpleExpr>,
{
pub fn into_expr(self) -> sea_query::SimpleExpr {
self.0
.map(|v| v.into())
.unwrap_or_else(|| sea_query::SimpleExpr::Custom("NULL".into()))
}
}
impl<T> From<CustomOption<T>> for sea_query::SimpleExpr
where
T: Into<sea_query::SimpleExpr>,
{
fn from(value: CustomOption<T>) -> Self {
value.into_expr()
}
}