Commits

Mike Bayer committed 6a01ace

- patch that makes MySQL rowcount work correctly! [ticket:396]

Comments (0)

Files changed (4)

 - fixed QueuePool bug whereby its better able to reconnect to a database
 that was not reachable (thanks to Sébastien Lelong), also fixed dispose()
 method
+- patch that makes MySQL rowcount work correctly! [ticket:396]
  
 0.3.2
 - major connection pool bug fixed.  fixes MySQL out of sync

lib/sqlalchemy/databases/mysql.py

 
 try:
     import MySQLdb as mysql
+    import MySQLdb.constants.CLIENT as CLIENT_FLAGS
 except:
     mysql = None
 
         coercetype('use_unicode', bool)   # this could break SA Unicode type
         coercetype('charset', str)        # this could break SA Unicode type
         # TODO: what about options like "ssl", "cursorclass" and "conv" ?
+
+        client_flag = opts.get('client_flag', 0)
+        client_flag |= CLIENT_FLAGS.FOUND_ROWS
+        opts['client_flag'] = client_flag
+
         return [[], opts]
 
     def create_execution_context(self):
         return sqltypes.adapt_type(typeobj, colspecs)
 
     def supports_sane_rowcount(self):
-        return False
+        return True
 
     def compiler(self, statement, bindparams, **kwargs):
         return MySQLCompiler(self, statement, bindparams, **kwargs)

lib/sqlalchemy/orm/mapper.py

                     mapper._postfetch(connection, table, obj, c, c.last_updated_params())
 
                     updated_objects.add(obj)
-                    rows += c.cursor.rowcount
+                    rows += c.rowcount
 
                 if c.supports_sane_rowcount() and rows != len(update):
                     raise exceptions.ConcurrentModificationError("Updated rowcount %d does not match number of objects updated %d" % (rows, len(update)))

test/orm/unitofwork.py

         version_table.delete().execute()
         UnitOfWorkTest.tearDown(self)
     
-    @testbase.unsupported('mysql', 'mssql')
+    @testbase.unsupported('mssql')
     def testbasic(self):
         s = create_session()
         class Foo(object):pass