dabo Commit
Revision 4830
Date: 2008-12-11 23:10:33 -0800 (Thu, 11 Dec 2008)
Author: Cito
Trac: http://trac.dabodev.com/dabo/changeset/4830

Changed:
U   trunk/dabo/db/dbPostgreSQL.py

Log:
Fixed wrong patch of dbPostgreSQL.getLastInsertID().

Diff:
Modified: trunk/dabo/db/dbPostgreSQL.py
===================================================================
--- trunk/dabo/db/dbPostgreSQL.py       2008-12-12 03:13:02 UTC (rev 4829)
+++ trunk/dabo/db/dbPostgreSQL.py       2008-12-12 07:10:33 UTC (rev 4830)
@@ -195,9 +195,9 @@
                currval() will return the correct value for each session.
 
                """
-
+               tableName = cursor.Table
                try:
-                       schemaName, tableName = cursor.Table.split(".", 1)
+                       schemaName, tableName = tableName.split(".", 1)
                except ValueError:
                        schemaName = None
 
@@ -205,23 +205,23 @@
                #on a serial data type to work.
                # special thanks to Lorenzo Alberton for his help with parsing 
of the fields.
                # It has been confirmed that the statement works with 7.4 
through 8.3.x
-               sql = ["SELECT substring((SELECT substring("
-                               "pg_get_expr(d.adbin, d.adrelid) for 128) as 
curval"
+               sql = ["SELECT currval(substring((SELECT substring("
+                               "pg_get_expr(d.adbin, d.adrelid) for 128)"
                                " FROM pg_attrdef d WHERE d.adrelid = 
a.attrelid"
                                " AND d.adnum = a.attnum AND a.atthasdef)"
-                               " FROM 'nextval[^'']*''([^'']*)')"
+                               " FROM 'nextval[^'']*''([^'']*)')) as currval"
                                " FROM pg_attribute a"
                                " LEFT JOIN pg_class c ON c.oid = a.attrelid"
                                " LEFT JOIN pg_attrdef d ON d.adrelid = 
a.attrelid"
                                " AND d.adnum = a.attnum AND a.atthasdef"
                                " LEFT JOIN pg_namespace n ON c.relnamespace = 
n.oid",
-                               " WHERE a.attname = '%s'" % cursor.KeyField,
-                               " AND (c.relname = '%s')" % tableName]
+                               "WHERE a.attname = '%s'" % cursor.KeyField,
+                               "AND (c.relname = '%s')" % tableName]
                if schemaName:
-                       sql.append(" AND n.nspname = '%s'" % schemaName)
+                       sql.append("AND n.nspname = '%s'" % schemaName)
                else:
-                       sql.append(" AND pg_table_is_visible(c.oid)")
-               sql.append(" AND NOT a.attisdropped AND a.attnum > 0"
+                       sql.append("AND pg_table_is_visible(c.oid)")
+               sql.append("AND NOT a.attisdropped AND a.attnum > 0"
                                " AND pg_get_expr(d.adbin, d.adrelid) LIKE 
'nextval%'")
 
                tempCursor = self._connection.cursor()




_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: 
http://leafe.com/archives/byMID/[email protected]

Reply via email to