mirror of
https://github.com/django/django.git
synced 2025-10-26 07:06:08 +00:00
Refactored get_date_trunc_sql() to DatabaseOperations.date_trunc_sql(). Refs #5106
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5952 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -24,6 +24,10 @@ class DatabaseOperations(BaseDatabaseOperations):
|
||||
# http://www.postgresql.org/docs/8.0/static/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT
|
||||
return "EXTRACT('%s' FROM %s)" % (lookup_type, field_name)
|
||||
|
||||
def date_trunc_sql(self, lookup_type, field_name):
|
||||
# http://www.postgresql.org/docs/8.0/static/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC
|
||||
return "DATE_TRUNC('%s', %s)" % (lookup_type, field_name)
|
||||
|
||||
class DatabaseWrapper(BaseDatabaseWrapper):
|
||||
ops = DatabaseOperations()
|
||||
|
||||
@@ -78,11 +82,6 @@ def get_last_insert_id(cursor, table_name, pk_name):
|
||||
cursor.execute("SELECT CURRVAL('\"%s_%s_seq\"')" % (table_name, pk_name))
|
||||
return cursor.fetchone()[0]
|
||||
|
||||
def get_date_trunc_sql(lookup_type, field_name):
|
||||
# lookup_type is 'year', 'month', 'day'
|
||||
# http://www.postgresql.org/docs/8.0/static/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC
|
||||
return "DATE_TRUNC('%s', %s)" % (lookup_type, field_name)
|
||||
|
||||
def get_datetime_cast_sql():
|
||||
return None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user