Ticket #6141: fix.diff
File fix.diff, 1.9 KB (added by , 17 years ago) |
---|
-
django/db/models/fields/__init__.py
209 209 210 210 def get_db_prep_lookup(self, lookup_type, value): 211 211 "Returns field's value prepared for database lookup." 212 if lookup_type in ('exact', 'regex', 'iregex', 'gt', 'gte', 'lt', 'lte', ' month', 'day', 'search'):212 if lookup_type in ('exact', 'regex', 'iregex', 'gt', 'gte', 'lt', 'lte', 'year', 'month', 'day', 'search'): 213 213 return [value] 214 214 elif lookup_type in ('range', 'in'): 215 215 return value … … 223 223 return ["%%%s" % prep_for_like_query(value)] 224 224 elif lookup_type == 'isnull': 225 225 return [] 226 elif lookup_type == 'year':227 try:228 value = int(value)229 except ValueError:230 raise ValueError("The __year lookup type requires an integer argument")231 return ['%s-01-01 00:00:00' % value, '%s-12-31 23:59:59.999999' % value]232 226 raise TypeError("Field has invalid lookup: %s" % lookup_type) 233 227 234 228 def has_default(self): -
django/db/models/query.py
807 807 return '%s IN (%s)' % (field_sql, in_string) 808 808 else: 809 809 raise EmptyResultSet 810 elif lookup_type in ('range', 'year'):810 elif lookup_type == 'range': 811 811 return '%s BETWEEN %%s AND %%s' % field_sql 812 elif lookup_type in (' month', 'day'):812 elif lookup_type in ('year', 'month', 'day'): 813 813 return "%s = %%s" % connection.ops.date_extract_sql(lookup_type, field_sql) 814 814 elif lookup_type == 'isnull': 815 815 return "%s IS %sNULL" % (field_sql, (not value and 'NOT ' or ''))