diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2006-02-18 20:18:45 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2006-02-18 20:18:45 +0000 |
| commit | 25b149a2a510df359f8fb485f32523d926b0150c (patch) | |
| tree | 42a5d536f0342ffb9e7cc8621781928ed0dcdbd7 | |
| parent | 73ddfd8bd2b0703573072809aa977d5ca335d101 (diff) | |
Fixed #1148 -- Fixed off-by-one error for some databases in get_DATEFIELD_list() at the edge of a year. Thanks, Hugo
git-svn-id: http://code.djangoproject.com/svn/django/trunk@2338 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/core/meta/__init__.py | 4 | ||||
| -rw-r--r-- | django/core/meta/fields.py | 4 |
2 files changed, 3 insertions, 5 deletions
diff --git a/django/core/meta/__init__.py b/django/core/meta/__init__.py index e9200d9a64..800975ef2a 100644 --- a/django/core/meta/__init__.py +++ b/django/core/meta/__init__.py @@ -1343,9 +1343,9 @@ def _get_where_clause(lookup_type, table_prefix, field_name, value): pass if lookup_type == 'in': return '%s%s IN (%s)' % (table_prefix, field_name, ','.join(['%s' for v in value])) - elif lookup_type in ('range', 'year'): + elif lookup_type == 'range': return '%s%s BETWEEN %%s AND %%s' % (table_prefix, field_name) - elif lookup_type in ('month', 'day'): + elif lookup_type in ('year', 'month', 'day'): return "%s = %%s" % db.get_date_extract_sql(lookup_type, table_prefix + field_name) elif lookup_type == 'isnull': return "%s%s IS %sNULL" % (table_prefix, field_name, (not value and 'NOT ' or '')) diff --git a/django/core/meta/fields.py b/django/core/meta/fields.py index ea9f5d4bcc..fe6eec5c97 100644 --- a/django/core/meta/fields.py +++ b/django/core/meta/fields.py @@ -175,12 +175,10 @@ class Field(object): def get_db_prep_lookup(self, lookup_type, value): "Returns field's value prepared for database lookup." - if lookup_type in ('exact', 'gt', 'gte', 'lt', 'lte', 'ne', 'month', 'day'): + if lookup_type in ('exact', 'gt', 'gte', 'lt', 'lte', 'ne', 'year', 'month', 'day'): return [value] elif lookup_type in ('range', 'in'): return value - elif lookup_type == 'year': - return ['%s-01-01' % value, '%s-12-31' % value] elif lookup_type in ('contains', 'icontains'): return ["%%%s%%" % prep_for_like_query(value)] elif lookup_type == 'iexact': |
