server: make negated string filters include null values

This commit is contained in:
William Holt 2023-12-16 23:41:24 +11:00
parent 190d795426
commit 1174cf4861

View file

@ -124,11 +124,11 @@ def apply_str_criterion_to_column(
transformer: Callable[[str], str] = wildcard_transformer,
) -> SaQuery:
if isinstance(criterion, criteria.PlainCriterion):
expr = column.ilike(transformer(criterion.value))
expr = sa.and_(column != None, column.ilike(transformer(criterion.value)))
elif isinstance(criterion, criteria.ArrayCriterion):
expr = sa.sql.false()
for value in criterion.values:
expr = expr | column.ilike(transformer(value))
expr = expr | sa.and_(column != None, column.ilike(transformer(value)))
elif isinstance(criterion, criteria.RangedCriterion):
raise errors.SearchError(
"Ranged criterion is invalid in this context. "