Django

Code

Changeset 2338

Show
Ignore:
Timestamp:
02/18/06 14:18:45 (3 years ago)
Author:
adrian
Message:

Fixed #1148 -- Fixed off-by-one error for some databases in get_DATEFIELD_list() at the edge of a year. Thanks, Hugo

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/core/meta/fields.py

    r2325 r2338  
    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)] 
  • django/trunk/django/core/meta/__init__.py

    r2176 r2338  
    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 == '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':