summaryrefslogtreecommitdiff
path: root/django/db/backends/postgresql/base.py
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2007-08-19 23:18:43 +0000
committerAdrian Holovaty <adrian@holovaty.com>2007-08-19 23:18:43 +0000
commit5ce050a5f5beab38e89b1e6a9c8b1c946252cd7f (patch)
tree4feab15da20e8f2bfeaffb93dd6ebf3c9193f457 /django/db/backends/postgresql/base.py
parent5a6426448f9813ef9abe17d59eb99e278f9461ee (diff)
Refactored get_last_insert_id() to DatabaseOperations.last_insert_id(). Refs #5106
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5958 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/backends/postgresql/base.py')
-rw-r--r--django/db/backends/postgresql/base.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/django/db/backends/postgresql/base.py b/django/db/backends/postgresql/base.py
index cb83200776..1642a51d7e 100644
--- a/django/db/backends/postgresql/base.py
+++ b/django/db/backends/postgresql/base.py
@@ -69,6 +69,10 @@ class DatabaseOperations(BaseDatabaseOperations):
def deferrable_sql(self):
return " DEFERRABLE INITIALLY DEFERRED"
+ def last_insert_id(self, cursor, table_name, pk_name):
+ cursor.execute("SELECT CURRVAL('\"%s_%s_seq\"')" % (table_name, pk_name))
+ return cursor.fetchone()[0]
+
class DatabaseWrapper(BaseDatabaseWrapper):
ops = DatabaseOperations()
@@ -127,10 +131,6 @@ def dictfetchall(cursor):
"Returns all rows from a cursor as a dict"
return cursor.dictfetchall()
-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_limit_offset_sql(limit, offset=None):
sql = "LIMIT %s" % limit
if offset and offset != 0: