always ignore empty Q objects, if the new Q is empty, the old one will be returned.

This commit is contained in:
Stephan Jaekel
2010-05-14 14:35:27 +02:00
parent 80c2895e56
commit f657432be3
2 changed files with 8 additions and 4 deletions

View File

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