Factored out database-specific date_extract behavior into dbmod.get_date_extract_sql(). Refs #46

git-svn-id: http://code.djangoproject.com/svn/django/trunk@159 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2005-07-17 18:23:34 +00:00
parent 35e81ce5af
commit 272b217557
4 changed files with 10 additions and 1 deletions

View file

@ -61,6 +61,10 @@ 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'
return "EXTRACT('%s' FROM %s)" % (lookup_type, table_name)
# Register these custom typecasts, because Django expects dates/times to be
# in Python's native (standard-library) datetime/time format, whereas psycopg
# use mx.DateTime by default.