Ticket #9596: dj_date_lookup.patch

File dj_date_lookup.patch, 2.2 KB (added by Scott <django@…>, 13 years ago)

Incomplete patch for date lookup type

Line 
1diff -rcrB django.orig/db/models/fields/__init__.py django/db/models/fields/__init__.py
2*** django.orig/db/models/fields/__init__.py    2008-09-01 19:15:35.000000000 -0300
3--- django/db/models/fields/__init__.py 2008-11-13 02:41:03.000000000 -0300
4***************
5*** 212,217 ****
6--- 212,219 ----
7              return ["%%%s" % connection.ops.prep_for_like_query(value)]
8          elif lookup_type == 'isnull':
9              return []
10+         elif lookup_type == 'date':
11+             return [connection.ops.value_to_db_date(value)]
12          elif lookup_type == 'year':
13              try:
14                  value = int(value)
15diff -rcrB django.orig/db/models/sql/constants.py django/db/models/sql/constants.py
16*** django.orig/db/models/sql/constants.py      2008-09-01 23:16:41.000000000 -0300
17--- django/db/models/sql/constants.py   2008-11-13 02:41:03.000000000 -0300
18***************
19*** 4,10 ****
20  QUERY_TERMS = dict([(x, None) for x in (
21      'exact', 'iexact', 'contains', 'icontains', 'gt', 'gte', 'lt', 'lte', 'in',
22      'startswith', 'istartswith', 'endswith', 'iendswith', 'range', 'year',
23!     'month', 'day', 'isnull', 'search', 'regex', 'iregex',
24      )])
25 
26  # Size of each "chunk" for get_iterator calls.
27--- 4,10 ----
28  QUERY_TERMS = dict([(x, None) for x in (
29      'exact', 'iexact', 'contains', 'icontains', 'gt', 'gte', 'lt', 'lte', 'in',
30      'startswith', 'istartswith', 'endswith', 'iendswith', 'range', 'year',
31!     'month', 'day', 'isnull', 'search', 'regex', 'iregex', 'date'
32      )])
33 
34  # Size of each "chunk" for get_iterator calls.
35diff -rcrB django.orig/db/models/sql/where.py django/db/models/sql/where.py
36*** django.orig/db/models/sql/where.py  2008-07-23 03:12:15.000000000 -0300
37--- django/db/models/sql/where.py       2008-11-13 02:48:38.000000000 -0300
38***************
39*** 172,177 ****
40--- 173,180 ----
41              return (connection.ops.fulltext_search_sql(field_sql), params)
42          elif lookup_type in ('regex', 'iregex'):
43              return connection.ops.regex_lookup(lookup_type) % (field_sql, cast_sql), params
44+         elif lookup_type == 'date':
45+             return ("date(%s) = %%s" % field_sql, params)
46 
47          raise TypeError('Invalid lookup_type: %r' % lookup_type)
48 
Back to Top