fix create_eid for sqlite (and bring back tests) stable
authorAlexandre Fayolle <alexandre.fayolle@logilab.fr>
Wed, 02 Jun 2010 18:12:27 +0200
branchstable
changeset 5644 73d8a757db80
parent 5642 6a90357b9769
child 5645 052eb526b939
child 5646 c9550c1239f0
fix create_eid for sqlite (and bring back tests)
server/sources/native.py
--- a/server/sources/native.py	Wed Jun 02 17:23:42 2010 +0000
+++ b/server/sources/native.py	Wed Jun 02 18:12:27 2010 +0200
@@ -270,6 +270,7 @@
             def pool_reset(cnx):
                 cnx.close()
             self.pool_reset = pool_reset
+            self.create_eid = self.__create_eid_sqlite
 
     @property
     def _sqlcnx(self):
@@ -729,6 +730,16 @@
         sql = self.dbhelper.sql_temporary_table(table, schema, False)
         self.doexec(session, sql)
 
+    def __create_eid_sqlite(self, session):
+        self._eid_creation_lock.acquire()
+        try:
+            for sql in self.dbhelper.sqls_increment_sequence('entities_id_seq'):
+                cursor = self.doexec(session, sql)
+            return cursor.fetchone()[0]
+        finally:
+            self._eid_creation_lock.release()
+
+
     def create_eid(self, session):
         self.debug('create eid')
         # lock needed to prevent 'Connection is busy with results for another command (0)' errors with SQLServer