Ticket #1148: year.diff
File year.diff, 1.6 KB (added by , 19 years ago) |
---|
-
core/meta/__init__.py
1343 1343 pass 1344 1344 if lookup_type == 'in': 1345 1345 return '%s%s IN (%s)' % (table_prefix, field_name, ','.join(['%s' for v in value])) 1346 elif lookup_type in ('range', 'year'):1346 elif lookup_type in ('range',): 1347 1347 return '%s%s BETWEEN %%s AND %%s' % (table_prefix, field_name) 1348 elif lookup_type in (' month', 'day'):1348 elif lookup_type in ('year', 'month', 'day'): 1349 1349 return "%s = %%s" % db.get_date_extract_sql(lookup_type, table_prefix + field_name) 1350 1350 elif lookup_type == 'isnull': 1351 1351 return "%s%s IS %sNULL" % (table_prefix, field_name, (not value and 'NOT ' or '')) -
core/meta/fields.py
175 175 176 176 def get_db_prep_lookup(self, lookup_type, value): 177 177 "Returns field's value prepared for database lookup." 178 if lookup_type in ('exact', 'gt', 'gte', 'lt', 'lte', 'ne', ' month', 'day'):178 if lookup_type in ('exact', 'gt', 'gte', 'lt', 'lte', 'ne', 'year', 'month', 'day'): 179 179 return [value] 180 180 elif lookup_type in ('range', 'in'): 181 181 return value 182 elif lookup_type == 'year':183 return ['%s-01-01' % value, '%s-12-31' % value]184 182 elif lookup_type in ('contains', 'icontains'): 185 183 return ["%%%s%%" % prep_for_like_query(value)] 186 184 elif lookup_type == 'iexact':