ignore empty Q objects when combining Q objects.

This commit is contained in:
Stephan Jaekel 2010-05-14 14:02:39 +02:00
parent 9df725165b
commit 4972bdb383

View File

@ -59,8 +59,10 @@ class Q(object):
def _combine(self, other, op): def _combine(self, other, op):
obj = Q() obj = Q()
obj.query = ['('] + copy.deepcopy(self.query) + [op] if self.query[0]:
obj.query += copy.deepcopy(other.query) + [')'] obj.query = ['('] + copy.deepcopy(self.query) + [op] + copy.deepcopy(other.query) + [')']
else:
obj.query = copy.deepcopy(other.query)
return obj return obj
def __or__(self, other): def __or__(self, other):