Ticket #6074: 6074_2.diff
File 6074_2.diff, 1.6 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) … … 721 722 where.extend(where2) 722 723 params.extend(params2) 723 724 except EmptyResultSet: 724 if not isinstance(self, QOr): 725 raise EmptyResultSet 725 failed+=1 726 if len(self.args)==failed: 727 raise EmptyResultSet 728 if not isinstance(self, QOr) and 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 """}