Ticket #6074: 6074-queryset-refactor.diff
File 6074-queryset-refactor.diff, 1.7 KB (added by , 17 years ago) |
---|
-
django/db/models/sql/where.py
42 42 return None, [] 43 43 result = [] 44 44 result_params = [] 45 if self.connection == OR: 46 failed = 0 45 47 for child in node.children: 46 48 if hasattr(child, 'as_sql'): 47 49 sql, params = child.as_sql(qn=qn) … … 60 62 if self.connection == AND and not node.negated: 61 63 # We can bail out early in this particular case (only). 62 64 raise 65 elif self.connection == OR: 66 failed += 1 63 67 sql = None 64 68 if sql: 65 69 result.append(format % sql) 66 70 result_params.extend(params) 71 if self.connection == OR and failed == len(node.children): 72 raise EmptyResultSet 67 73 conn = ' %s ' % node.connection 68 74 return conn.join(result), result_params 69 75 -
tests/modeltests/or_lookups/models.py
125 125 [<Article: Hello>] 126 126 >>> Article.objects.complex_filter(Q(pk=1) | Q(pk=2)) 127 127 [<Article: Hello>, <Article: Goodbye>] 128 129 # Check that Q(id__in=[]) returns the same results as Q(id__in=[]) | Q(id__in=[]) when used with filter : 130 >>> Article.objects.filter(Q(id__in=[]) | Q(id__in=[])) 131 [] 132 >>> Article.objects.filter(Q(id__in=[]) | Q(id=1) |Q(id__in=[])) 133 [<Article: Hello>] 128 134 """}