From c5d16a3ca956ab717ff1b25ecb51580163389ed6 Mon Sep 17 00:00:00 2001 From: olliemath Date: Wed, 28 Jul 2021 09:24:24 +0100 Subject: [PATCH] Bugfix: allow Q to be subclassed --- clickhouse_orm/query.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/clickhouse_orm/query.py b/clickhouse_orm/query.py index 885feb1..7287350 100644 --- a/clickhouse_orm/query.py +++ b/clickhouse_orm/query.py @@ -221,7 +221,7 @@ class Q(object): q._children.append(deepcopy(l_child)) else: # Different modes - q = Q() + q = cls() q._children = [l_child, r_child] q._mode = mode # AND/OR @@ -259,10 +259,10 @@ class Q(object): return sql def __or__(self, other): - return Q._construct_from(self, other, self.OR_MODE) + return self.__class__._construct_from(self, other, self.OR_MODE) def __and__(self, other): - return Q._construct_from(self, other, self.AND_MODE) + return self.__class__._construct_from(self, other, self.AND_MODE) def __invert__(self): q = copy(self) @@ -273,7 +273,7 @@ class Q(object): return not self.is_empty def __deepcopy__(self, memo): - q = Q() + q = self.__class__() q._conds = [deepcopy(cond) for cond in self._conds] q._negate = self._negate q._mode = self._mode