Ticket #7672: dayofweek_filter-r7866.diff
File dayofweek_filter-r7866.diff, 3.5 KB (added by , 16 years ago) |
---|
-
django/db/models/sql/where.py
152 152 params) 153 153 elif lookup_type in ('range', 'year'): 154 154 return ('%s BETWEEN %%s and %%s' % field_sql, params) 155 elif lookup_type in ('month', 'day' ):155 elif lookup_type in ('month', 'day', 'dow'): 156 156 return ('%s = %%s' % connection.ops.date_extract_sql(lookup_type, 157 157 field_sql), params) 158 158 elif lookup_type == 'isnull': -
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', 'dow', 'isnull', 'search', 'regex', 'iregex', 8 8 )]) 9 9 10 10 # Size of each "chunk" for get_iterator calls. -
django/db/models/fields/__init__.py
233 233 if hasattr(value, 'as_sql'): 234 234 sql, params = value.as_sql() 235 235 return QueryWrapper(('(%s)' % sql), params) 236 if lookup_type in ('exact', 'regex', 'iregex', 'gt', 'gte', 'lt', 'lte', 'month', 'day', ' search'):236 if lookup_type in ('exact', 'regex', 'iregex', 'gt', 'gte', 'lt', 'lte', 'month', 'day', 'dow', 'search'): 237 237 return [value] 238 238 elif lookup_type in ('range', 'in'): 239 239 return value -
django/db/backends/mysql/base.py
68 68 class DatabaseOperations(BaseDatabaseOperations): 69 69 def date_extract_sql(self, lookup_type, field_name): 70 70 # http://dev.mysql.com/doc/mysql/en/date-and-time-functions.html 71 return "EXTRACT(%s FROM %s)" % (lookup_type.upper(), field_name) 71 if lookup_type == 'dow': 72 return "DAYOFWEEK(%s)" % field_name 73 else: 74 return "EXTRACT(%s FROM %s)" % (lookup_type.upper(), field_name) 72 75 73 76 def date_trunc_sql(self, lookup_type, field_name): 74 77 fields = ['year', 'month', 'day', 'hour', 'minute', 'second'] -
django/db/backends/oracle/base.py
56 56 57 57 def date_extract_sql(self, lookup_type, field_name): 58 58 # http://download-east.oracle.com/docs/cd/B10501_01/server.920/a96540/functions42a.htm#1017163 59 return "EXTRACT(%s FROM %s)" % (lookup_type, field_name) 59 if lookup_type == 'dow': 60 return "TO_CHAR(%s, 'D')" % field_name 61 else: 62 return "EXTRACT(%s FROM %s)" % (lookup_type, field_name) 60 63 61 64 def date_trunc_sql(self, lookup_type, field_name): 62 65 # Oracle uses TRUNC() for both dates and numbers.