Ticket #9596: dj_date_lookup_c.patch
File dj_date_lookup_c.patch, 2.6 KB (added by , 16 years ago) |
---|
-
django/db/models/sql/where.py
160 160 return ('%s IN %s' % (field_sql, extra), params) 161 161 return ('%s IN (%s)' % (field_sql, ', '.join(['%s'] * len(params))), 162 162 params) 163 elif lookup_type in ('range', 'year' ):163 elif lookup_type in ('range', 'year', 'date'): 164 164 return ('%s BETWEEN %%s and %%s' % field_sql, params) 165 165 elif lookup_type in ('month', 'day'): 166 166 return ('%s = %%s' % connection.ops.date_extract_sql(lookup_type, -
django/db/models/sql/constants.py
4 4 QUERY_TERMS = dict([(x, None) for x in ( 5 5 'exact', 'iexact', 'contains', 'icontains', 'gt', 'gte', 'lt', 'lte', 'in', 6 6 'startswith', 'istartswith', 'endswith', 'iendswith', 'range', 'year', 7 'month', 'day', 'isnull', 'search', 'regex', 'iregex', 7 'month', 'day', 'isnull', 'search', 'regex', 'iregex', 'date', 8 8 )]) 9 9 10 10 # Size of each "chunk" for get_iterator calls. -
django/db/models/fields/__init__.py
212 212 return ["%%%s" % connection.ops.prep_for_like_query(value)] 213 213 elif lookup_type == 'isnull': 214 214 return [] 215 elif lookup_type == 'date': 216 return self.get_db_prep_lookup('range', (datetime.datetime.combine(value, datetime.time.min), 217 datetime.datetime.combine(value, datetime.time.max))) 215 218 elif lookup_type == 'year': 216 219 try: 217 220 value = int(value) -
docs/ref/models/querysets.txt
1156 1156 You can use ``range`` anywhere you can use ``BETWEEN`` in SQL -- for dates, 1157 1157 numbers and even characters. 1158 1158 1159 date 1160 ~~~~ 1161 1162 Tests datetime fields for date equality, disregarding time. 1163 1164 Example:: 1165 1166 yesterday = datetime.date.today() - datetime.timedelta(1) 1167 Entry.objects.filter(pub_date__date = yesterday) 1168 1169 SQL equivalent:: 1170 1171 SELECT ... WHERE pub_date BETWEEN '2008-11-12' and '2008-11-12'; 1172 1159 1173 year 1160 1174 ~~~~ 1161 1175