Ticket #6074: 6074_3.diff
File 6074_3.diff, 1.5 KB (added by , 17 years ago) |
---|
-
django/db/models/query.py
714 714 715 715 def get_sql(self, opts): 716 716 joins, where, params = SortedDict(), [], [] 717 failed = 0 717 718 for val in self.args: 718 719 try: 719 720 joins2, where2, params2 = val.get_sql(opts) … … 723 724 except EmptyResultSet: 724 725 if not isinstance(self, QOr): 725 726 raise EmptyResultSet 727 failed+=1 728 if len(self.args)==failed: 729 raise EmptyResultSet 726 730 if where: 727 731 return joins, ['(%s)' % self.operator.join(where)], params 728 732 return joins, [], params -
tests/modeltests/or_lookups/models.py
116 116 [<Article: Hello>] 117 117 >>> Article.objects.complex_filter(Q(pk=1) | Q(pk=2)) 118 118 [<Article: Hello>, <Article: Goodbye>] 119 120 # Check that Q(pk__in=[]) returns the same results as Q(pk__in=[]) | Q(pk__in=[]) when used with filter : 121 >>> Article.objects.filter(Q(pk__in=[]) | Q(pk__in=[])) 122 [] 123 124 # But with Q(pk__in=[]) | Q(pk__in=[1,]) | Q(pk__in=[]) it must return something : 125 >>> Article.objects.filter(Q(pk__in=[]) | Q(pk__in=[1,]) | Q(pk__in=[])) 126 [<Article: Hello>] 127 119 128 """}