#267 Added is_null
and is_not_null
This commit is contained in:
parent
4913e88f3a
commit
5daa9abd38
@ -47,8 +47,9 @@ macro_rules! bind_oper {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! bind_agg_func {
|
macro_rules! bind_func_no_params {
|
||||||
( $func: ident ) => {
|
( $func: ident ) => {
|
||||||
|
/// See also SeaQuery's method with same name.
|
||||||
fn $func(&self) -> SimpleExpr {
|
fn $func(&self) -> SimpleExpr {
|
||||||
Expr::tbl(self.entity_name(), *self).$func()
|
Expr::tbl(self.entity_name(), *self).$func()
|
||||||
}
|
}
|
||||||
@ -213,10 +214,12 @@ pub trait ColumnTrait: IdenStatic + Iterable + FromStr {
|
|||||||
Expr::tbl(self.entity_name(), *self).like(&pattern)
|
Expr::tbl(self.entity_name(), *self).like(&pattern)
|
||||||
}
|
}
|
||||||
|
|
||||||
bind_agg_func!(max);
|
bind_func_no_params!(max);
|
||||||
bind_agg_func!(min);
|
bind_func_no_params!(min);
|
||||||
bind_agg_func!(sum);
|
bind_func_no_params!(sum);
|
||||||
bind_agg_func!(count);
|
bind_func_no_params!(count);
|
||||||
|
bind_func_no_params!(is_null);
|
||||||
|
bind_func_no_params!(is_not_null);
|
||||||
|
|
||||||
fn if_null<V>(&self, v: V) -> SimpleExpr
|
fn if_null<V>(&self, v: V) -> SimpleExpr
|
||||||
where
|
where
|
||||||
|
@ -340,6 +340,18 @@ pub trait QueryFilter: Sized {
|
|||||||
/// r#"SELECT "cake"."id", "cake"."name" FROM "cake" WHERE (NOT (1 = 1 AND 2 = 2)) AND (3 = 3 OR 4 = 4)"#
|
/// r#"SELECT "cake"."id", "cake"."name" FROM "cake" WHERE (NOT (1 = 1 AND 2 = 2)) AND (3 = 3 OR 4 = 4)"#
|
||||||
/// );
|
/// );
|
||||||
/// ```
|
/// ```
|
||||||
|
/// Use a sea_query expression
|
||||||
|
/// ```
|
||||||
|
/// use sea_orm::{entity::*, query::*, sea_query::Expr, tests_cfg::fruit, DbBackend};
|
||||||
|
///
|
||||||
|
/// assert_eq!(
|
||||||
|
/// fruit::Entity::find()
|
||||||
|
/// .filter(Expr::col(fruit::Column::CakeId).is_null())
|
||||||
|
/// .build(DbBackend::MySql)
|
||||||
|
/// .to_string(),
|
||||||
|
/// "SELECT `fruit`.`id`, `fruit`.`name`, `fruit`.`cake_id` FROM `fruit` WHERE `cake_id` IS NULL"
|
||||||
|
/// );
|
||||||
|
/// ```
|
||||||
fn filter<F>(mut self, filter: F) -> Self
|
fn filter<F>(mut self, filter: F) -> Self
|
||||||
where
|
where
|
||||||
F: IntoCondition,
|
F: IntoCondition,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user