Loading django/db/models/query.py +10 −0 Original line number Diff line number Diff line Loading @@ -218,6 +218,8 @@ class QuerySet(object): def __and__(self, other): self._merge_sanity_check(other) if isinstance(other, EmptyQuerySet): return other._clone() combined = self._clone() combined.query.combine(other.query, sql.AND) return combined Loading @@ -225,6 +227,8 @@ class QuerySet(object): def __or__(self, other): self._merge_sanity_check(other) combined = self._clone() if isinstance(other, EmptyQuerySet): return combined combined.query.combine(other.query, sql.OR) return combined Loading Loading @@ -705,6 +709,12 @@ class EmptyQuerySet(QuerySet): super(EmptyQuerySet, self).__init__(model, query) self._result_cache = [] def __and__(self, other): return self._clone() def __or__(self, other): return other._clone() def count(self): return 0 Loading tests/regressiontests/queries/models.py +10 −0 Original line number Diff line number Diff line Loading @@ -781,5 +781,15 @@ Bug #7107 -- this shouldn't create an infinite loop. >>> Valid.objects.all() [] Empty querysets can be merged with others. >>> Note.objects.none() | Note.objects.all() [<Note: n1>, <Note: n2>, <Note: n3>] >>> Note.objects.all() | Note.objects.none() [<Note: n1>, <Note: n2>, <Note: n3>] >>> Note.objects.none() & Note.objects.all() [] >>> Note.objects.all() & Note.objects.none() [] """} Loading
django/db/models/query.py +10 −0 Original line number Diff line number Diff line Loading @@ -218,6 +218,8 @@ class QuerySet(object): def __and__(self, other): self._merge_sanity_check(other) if isinstance(other, EmptyQuerySet): return other._clone() combined = self._clone() combined.query.combine(other.query, sql.AND) return combined Loading @@ -225,6 +227,8 @@ class QuerySet(object): def __or__(self, other): self._merge_sanity_check(other) combined = self._clone() if isinstance(other, EmptyQuerySet): return combined combined.query.combine(other.query, sql.OR) return combined Loading Loading @@ -705,6 +709,12 @@ class EmptyQuerySet(QuerySet): super(EmptyQuerySet, self).__init__(model, query) self._result_cache = [] def __and__(self, other): return self._clone() def __or__(self, other): return other._clone() def count(self): return 0 Loading
tests/regressiontests/queries/models.py +10 −0 Original line number Diff line number Diff line Loading @@ -781,5 +781,15 @@ Bug #7107 -- this shouldn't create an infinite loop. >>> Valid.objects.all() [] Empty querysets can be merged with others. >>> Note.objects.none() | Note.objects.all() [<Note: n1>, <Note: n2>, <Note: n3>] >>> Note.objects.all() | Note.objects.none() [<Note: n1>, <Note: n2>, <Note: n3>] >>> Note.objects.none() & Note.objects.all() [] >>> Note.objects.all() & Note.objects.none() [] """}