From 1174cf48611608ed016203655ba5381ec065e99d Mon Sep 17 00:00:00 2001 From: William Holt Date: Sat, 16 Dec 2023 23:41:24 +1100 Subject: [PATCH] server: make negated string filters include null values --- server/szurubooru/search/configs/util.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/szurubooru/search/configs/util.py b/server/szurubooru/search/configs/util.py index 58e6ebe5..5861d3dc 100644 --- a/server/szurubooru/search/configs/util.py +++ b/server/szurubooru/search/configs/util.py @@ -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. "