def _build_criterion_expression( self, operator_: str, left: Term, right: Term) -> Union[BasicCriterion, Not, NullCriterion]: if operator_ == "equals": return left.eq(right) elif operator_ == "not-equals": return left.ne(right) elif operator_ == 'empty': return left.isnull() elif operator_ == 'not-empty': return left.notnull() elif operator_ == "more": return left.gt(right) elif operator_ == "more-equals": return left.gte(right) elif operator_ == "less": return left.lt(right) elif operator_ == "less-equals": return left.lte(right) elif operator_ == 'in': return left.isin(right) elif operator_ == 'not-in': return left.notin(right) else: # TODO more operator support raise NotImplementedError("filter operator is not supported")
def not_null(field: Term, value: Any) -> Criterion: if value: return field.notnull() return field.isnull()