Ticket #1148: year.diff

File year.diff, 1.6 KB (added by hugo, 19 years ago)

patch to change year to same behaviour as month

  • core/meta/__init__.py

     
    13431343        pass
    13441344    if lookup_type == 'in':
    13451345        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',):
    13471347        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'):
    13491349        return "%s = %%s" % db.get_date_extract_sql(lookup_type, table_prefix + field_name)
    13501350    elif lookup_type == 'isnull':
    13511351        return "%s%s IS %sNULL" % (table_prefix, field_name, (not value and 'NOT ' or ''))
  • core/meta/fields.py

     
    175175
    176176    def get_db_prep_lookup(self, lookup_type, value):
    177177        "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'):
    179179            return [value]
    180180        elif lookup_type in ('range', 'in'):
    181181            return value
    182         elif lookup_type == 'year':
    183             return ['%s-01-01' % value, '%s-12-31' % value]
    184182        elif lookup_type in ('contains', 'icontains'):
    185183            return ["%%%s%%" % prep_for_like_query(value)]
    186184        elif lookup_type == 'iexact':
Back to Top