mirror of
https://github.com/django/django.git
synced 2025-09-11 13:06:29 +00:00
Refactored get_date_extract_sql() to DatabaseOperations.date_extract_sql(). Refs #5106
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5951 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
38b5d7f23d
commit
aab04a4c2f
10 changed files with 30 additions and 43 deletions
|
@ -54,7 +54,9 @@ server_version_re = re.compile(r'(\d{1,2})\.(\d{1,2})\.(\d{1,2})')
|
|||
# TRADITIONAL will automatically cause most warnings to be treated as errors.
|
||||
|
||||
class DatabaseOperations(BaseDatabaseOperations):
|
||||
pass
|
||||
def date_extract_sql(self, lookup_type, field_name):
|
||||
# http://dev.mysql.com/doc/mysql/en/date-and-time-functions.html
|
||||
return "EXTRACT(%s FROM %s)" % (lookup_type.upper(), field_name)
|
||||
|
||||
class DatabaseWrapper(BaseDatabaseWrapper):
|
||||
ops = DatabaseOperations()
|
||||
|
@ -137,11 +139,6 @@ dictfetchall = util.dictfetchall
|
|||
def get_last_insert_id(cursor, table_name, pk_name):
|
||||
return cursor.lastrowid
|
||||
|
||||
def get_date_extract_sql(lookup_type, table_name):
|
||||
# lookup_type is 'year', 'month', 'day'
|
||||
# http://dev.mysql.com/doc/mysql/en/date-and-time-functions.html
|
||||
return "EXTRACT(%s FROM %s)" % (lookup_type.upper(), table_name)
|
||||
|
||||
def get_date_trunc_sql(lookup_type, field_name):
|
||||
# lookup_type is 'year', 'month', 'day'
|
||||
fields = ['year', 'month', 'day', 'hour', 'minute', 'second']
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue