[Modeling-cvs] SF.net SVN: modeling: [1001] trunk/ProjectModeling
Status: Abandoned
Brought to you by:
sbigaret
From: <sbi...@us...> - 2006-04-22 22:22:51
|
Revision: 1001 Author: sbigaret Date: 2006-04-22 15:22:45 -0700 (Sat, 22 Apr 2006) ViewCVS: http://svn.sourceforge.net/modeling/?rev=1001&view=rev Log Message: ----------- Feature Request #978800 extended for MySQL: PKs are also fetched in a single request (instead of n requests in one transaction) Modified Paths: -------------- trunk/ProjectModeling/CHANGES trunk/ProjectModeling/Modeling/DatabaseAdaptors/MySQLAdaptorLayer/MySQLAdaptorChannel.py Modified: trunk/ProjectModeling/CHANGES =================================================================== --- trunk/ProjectModeling/CHANGES 2006-04-22 19:07:12 UTC (rev 1000) +++ trunk/ProjectModeling/CHANGES 2006-04-22 22:22:45 UTC (rev 1001) @@ -7,8 +7,12 @@ ** Distributed under a 3-clause BSD-style license, see LICENSE for details ** ----------------------------------------------------------------------------- + * Feature Request #978800 extended for MySQL: PKs are also fetched in a + single request (instead of n requests in one transaction) + * Feature Request #978800: "SQLite adaptor: get X primary keys at once" - PKs are now retrieved in a single request. + PKs are now retrieved in a single request (instead of n requests in one + transaction) * Fixed bug #1474720: when saving changes, the PKs needed for the inserted objects are retrieved one after the other, opening and closing a Modified: trunk/ProjectModeling/Modeling/DatabaseAdaptors/MySQLAdaptorLayer/MySQLAdaptorChannel.py =================================================================== --- trunk/ProjectModeling/Modeling/DatabaseAdaptors/MySQLAdaptorLayer/MySQLAdaptorChannel.py 2006-04-22 19:07:12 UTC (rev 1000) +++ trunk/ProjectModeling/Modeling/DatabaseAdaptors/MySQLAdaptorLayer/MySQLAdaptorChannel.py 2006-04-22 22:22:45 UTC (rev 1001) @@ -68,23 +68,23 @@ try: pkName=anEntity.primaryKeyAttributeNames()[0] pkRootName=anEntity.primaryKeyRootName() - statements=["UPDATE PK_SEQ_%s SET id=LAST_INSERT_ID(id+1)"%pkRootName, + statements=["UPDATE PK_SEQ_%s SET id=LAST_INSERT_ID(id+%i)"%(pkRootName,count), "select LAST_INSERT_ID()"] result=[] - for idx in range(count): - for statement in statements: - db_info('Evaluating: %s'%statement) - try: - self.dbAPI_cursor().execute(statement) - except: - exctype, value = sys.exc_info()[:2] - msg="Couldn't evaluate expression %s. Reason: %s:%s"%(statement, exctype, value) - db_error(msg) - raise GeneralAdaptorException, msg - - MySQLAdaptorChannel._count_for_execute+=1 + for statement in statements: + db_info('Evaluating: %s'%statement) + try: + self.dbAPI_cursor().execute(statement) + except: + exctype, value = sys.exc_info()[:2] + msg="Couldn't evaluate expression %s. Reason: %s:%s"%(statement, exctype, value) + db_error(msg) + raise GeneralAdaptorException, msg + + MySQLAdaptorChannel._count_for_execute+=1 - result.append({pkName :self.dbAPI_cursor().fetchone()[0]}) + result = self.dbAPI_cursor().fetchone()[0] + result = [{pkName : v+1} for v in range(result-count,result)] return tuple(result) finally: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |