1
0
mirror of https://github.com/django/django.git synced 2025-10-25 22:56:12 +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:
Adrian Holovaty
2007-08-19 22:40:06 +00:00
parent 38b5d7f23d
commit aab04a4c2f
10 changed files with 30 additions and 43 deletions

View File

@@ -20,7 +20,9 @@ psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
postgres_version = None
class DatabaseOperations(BaseDatabaseOperations):
pass
def date_extract_sql(self, lookup_type, field_name):
# http://www.postgresql.org/docs/8.0/static/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT
return "EXTRACT('%s' FROM %s)" % (lookup_type, field_name)
class DatabaseWrapper(BaseDatabaseWrapper):
ops = DatabaseOperations()
@@ -76,11 +78,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_extract_sql(lookup_type, table_name):
# lookup_type is 'year', 'month', 'day'
# http://www.postgresql.org/docs/8.0/static/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT
return "EXTRACT('%s' FROM %s)" % (lookup_type, table_name)
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