Fixed invalid condtion joins in _filter_or_exclude (multiple_exclude_test)

This commit is contained in:
M1ha 2018-12-17 10:26:35 +05:00
parent 375316fbf3
commit d1e61dc420

View File

@ -411,9 +411,10 @@ class QuerySet(object):
def _filter_or_exclude(self, *q, **kwargs): def _filter_or_exclude(self, *q, **kwargs):
reverse = kwargs.pop('reverse', False) reverse = kwargs.pop('reverse', False)
prewhere = kwargs.pop('prewhere', False) prewhere = kwargs.pop('prewhere', False)
condition = copy(self._where_q)
qs = copy(self) qs = copy(self)
condition = Q()
for q_obj in q: for q_obj in q:
condition &= q_obj condition &= q_obj
@ -423,6 +424,7 @@ class QuerySet(object):
if reverse: if reverse:
condition = ~condition condition = ~condition
condition = copy(self._prewhere_q if prewhere else self._where_q) & condition
if prewhere: if prewhere:
qs._prewhere_q = condition qs._prewhere_q = condition
else: else: