server/search: fix negating complex searches
Entering: miko -miko is a contradiction that shouldn't have been returning any matches, but it has nonetheless. This change fixes the construction of negated expressions that use subqueries.
This commit is contained in:
parent
22342a29ad
commit
c366b608da
1 changed files with 5 additions and 2 deletions
|
@ -127,8 +127,11 @@ def create_subquery_filter(
|
||||||
if subquery_decorator:
|
if subquery_decorator:
|
||||||
subquery = subquery_decorator(subquery)
|
subquery = subquery_decorator(subquery)
|
||||||
subquery = subquery.options(sqlalchemy.orm.lazyload('*'))
|
subquery = subquery.options(sqlalchemy.orm.lazyload('*'))
|
||||||
subquery = filter_func(subquery, criterion, negated)
|
subquery = filter_func(subquery, criterion, False)
|
||||||
subquery = subquery.subquery('t')
|
subquery = subquery.subquery('t')
|
||||||
return query.filter(left_id_column.in_(subquery))
|
expression = left_id_column.in_(subquery)
|
||||||
|
if negated:
|
||||||
|
expression = ~expression
|
||||||
|
return query.filter(expression)
|
||||||
|
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
Loading…
Reference in a new issue