Author: phd
Date: 2009-09-09 13:47:01 -0600 (Wed, 09 Sep 2009)
New Revision: 3973
Modified:
SQLObject/branches/0.10/sqlobject/sybase/sybaseconnection.py
Log:
Applied patch 2855422: Sybase tables with identity column fire two identity_inserts.
Modified: SQLObject/branches/0.10/sqlobject/sybase/sybaseconnection.py
===================================================================
--- SQLObject/branches/0.10/sqlobject/sybase/sybaseconnection.py 2009-09-08 17:58:32 UTC (rev 3972)
+++ SQLObject/branches/0.10/sqlobject/sybase/sybaseconnection.py 2009-09-09 19:47:01 UTC (rev 3973)
@@ -76,17 +76,16 @@
values = [id] + values
has_identity = self._hasIdentity(conn, table)
- if has_identity:
- if id is not None:
- c.execute('SET IDENTITY_INSERT %s ON' % table)
- else:
- c.execute('SET IDENTITY_INSERT %s OFF' % table)
+ identity_insert_on = False
+ if has_identity and (id is not None):
+ identity_insert_on = True
+ c.execute('SET IDENTITY_INSERT %s ON' % table)
q = self._insertSQL(table, names, values)
if self.debug:
print 'QueryIns: %s' % q
c.execute(q)
- if has_identity:
+ if has_identity and identity_insert_on:
c.execute('SET IDENTITY_INSERT %s OFF' % table)
if id is None:
id = self.insert_id(conn)
|