From d1e61dc420af7ce7dd71e832693ba9453b68e624 Mon Sep 17 00:00:00 2001 From: M1ha Date: Mon, 17 Dec 2018 10:26:35 +0500 Subject: [PATCH] Fixed invalid condtion joins in _filter_or_exclude (multiple_exclude_test) --- src/infi/clickhouse_orm/query.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/infi/clickhouse_orm/query.py b/src/infi/clickhouse_orm/query.py index 22c1484..b705320 100644 --- a/src/infi/clickhouse_orm/query.py +++ b/src/infi/clickhouse_orm/query.py @@ -411,9 +411,10 @@ class QuerySet(object): def _filter_or_exclude(self, *q, **kwargs): reverse = kwargs.pop('reverse', False) prewhere = kwargs.pop('prewhere', False) - condition = copy(self._where_q) + qs = copy(self) + condition = Q() for q_obj in q: condition &= q_obj @@ -423,6 +424,7 @@ class QuerySet(object): if reverse: condition = ~condition + condition = copy(self._prewhere_q if prewhere else self._where_q) & condition if prewhere: qs._prewhere_q = condition else: