From a73a097301aef33437af72397cdb860bd5e8048b Mon Sep 17 00:00:00 2001 From: James Burke Date: Thu, 19 Jan 2017 08:19:12 +0100 Subject: [PATCH] return uuid on insert --- pydal/adapters/postgres.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pydal/adapters/postgres.py b/pydal/adapters/postgres.py index e132330e9..2b46e3f0f 100644 --- a/pydal/adapters/postgres.py +++ b/pydal/adapters/postgres.py @@ -105,7 +105,11 @@ def after_connection(self): def lastrowid(self, table): if self._last_insert: - return long(self.cursor.fetchone()[0]) + pk = self.cursor.fetchone()[0] + try: + return long(pk) + except ValueError: + return str(pk) sequence_name = table._sequence_name self.execute("SELECT currval(%s);" % self.adapt(sequence_name)) return long(self.cursor.fetchone()[0])