1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
use super::super::sql; use super::super::expression; use super::super::field; use super::ToSharedPredicate; #[derive(Clone, Debug)] pub struct IsNullPredicate<F> { field: F, is_null: bool } impl<F> IsNullPredicate<F> { pub fn get_field(&self) -> &F { &self.field } pub fn is_null(&self) -> bool { self.is_null } } pub trait ToIsNullPredicate { fn is_null(&self) -> super::SharedPredicate; fn not_null(&self) -> super::SharedPredicate; } impl<F> super::Predicate for IsNullPredicate<F> where F: sql::ToPredicateValue {} impl<T> ToIsNullPredicate for field::NamedField<Option<T>> where T: sql::ToPredicateValue + Clone + 'static { fn is_null(&self) -> super::SharedPredicate { IsNullPredicate { field: self.clone(), is_null: true }.upcast() } fn not_null(&self) -> super::SharedPredicate { IsNullPredicate { field: self.clone(), is_null: false }.upcast() } } impl ToIsNullPredicate for expression::RawExpression { fn is_null(&self) -> super::SharedPredicate { IsNullPredicate { field: self.clone(), is_null: true }.upcast() } fn not_null(&self) -> super::SharedPredicate { IsNullPredicate { field: self.clone(), is_null: false }.upcast() } }