Ticket #6065: sql_notin.patch
File sql_notin.patch, 1.7 KB (added by , 17 years ago) |
---|
-
django/db/models/fields/__init__.py
211 211 "Returns field's value prepared for database lookup." 212 212 if lookup_type in ('exact', 'regex', 'iregex', 'gt', 'gte', 'lt', 'lte', 'month', 'day', 'search'): 213 213 return [value] 214 elif lookup_type in ('range', 'in' ):214 elif lookup_type in ('range', 'in', 'notin'): 215 215 return value 216 216 elif lookup_type in ('contains', 'icontains'): 217 217 return ["%%%s%%" % prep_for_like_query(value)] -
django/db/models/query.py
21 21 # The list of valid query types 22 22 QUERY_TERMS = ( 23 23 'exact', 'iexact', 'contains', 'icontains', 24 'gt', 'gte', 'lt', 'lte', 'in', 24 'gt', 'gte', 'lt', 'lte', 'in', 'notin', 25 25 'startswith', 'istartswith', 'endswith', 'iendswith', 26 26 'range', 'year', 'month', 'day', 'isnull', 'search', 27 27 'regex', 'iregex', … … 806 806 return '%s IN (%s)' % (field_sql, in_string) 807 807 else: 808 808 raise EmptyResultSet 809 elif lookup_type == 'notin': 810 in_string = ','.join(['%s' for id in value]) 811 if in_string: 812 return '%s NOT IN (%s)' % (field_sql, in_string) 813 else: 814 raise EmptyResultSet 809 815 elif lookup_type in ('range', 'year'): 810 816 return '%s BETWEEN %%s AND %%s' % field_sql 811 817 elif lookup_type in ('month', 'day'):