Ticket #13579: 13579.patch
File 13579.patch, 1.9 KB (added by , 14 years ago) |
---|
-
django/db/models/sql/where.py
176 176 if lookup_type == 'in': 177 177 if not value_annot: 178 178 raise EmptyResultSet 179 if extra: 180 return ('%s IN %s' % (field_sql, extra), params) 181 return ('%s IN (%s)' % (field_sql, ', '.join(['%s'] * len(params))), 182 params) 179 if None in params: 180 params = [param for param in params if param is not None] 181 if extra: 182 return ('%s IS NULL OR %s IN %s' % (field_sql, field_sql, 183 extra), params) 184 return ('%s IS NULL OR %s IN (%s)' % 185 (field_sql, field_sql, ', '.join(['%s'] * len(params))), 186 params) 187 else: 188 if extra: 189 return ('%s IN %s' % (field_sql, extra), params) 190 return ('%s IN (%s)' % 191 (field_sql, ', '.join(['%s'] * len(params))), params) 183 192 elif lookup_type in ('range', 'year'): 184 193 return ('%s BETWEEN %%s and %%s' % field_sql, params) 185 194 elif lookup_type in ('month', 'day', 'week_day'): -
tests/regressiontests/null_queries/models.py
78 78 >>> Inner.objects.filter(first__inner__second=None) 79 79 [<Inner: Inner object>] 80 80 81 >>> bobj = OuterB.objects.create(data="") 82 >>> _ = Inner.objects.create(first=obj, second=bobj) 83 >>> Inner.objects.filter(second__in=[None,]).count() 84 1 85 >>> Inner.objects.filter(second__in=[None, bobj]).count() 86 2 81 87 82 88 """}