From: Mike Bayer Date: Mon, 29 Apr 2013 23:49:28 +0000 (-0400) Subject: Updated mysqlconnector dialect to check for disconnect based X-Git-Tag: rel_0_8_2~81^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eb431e4aa5a0dbf3af73497289aade857cf70233;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Updated mysqlconnector dialect to check for disconnect based on the apparent string message sent in the exception; tested against mysqlconnector 1.0.9. --- diff --git a/doc/build/changelog/changelog_08.rst b/doc/build/changelog/changelog_08.rst index 3fda776f2c..ed95398911 100644 --- a/doc/build/changelog/changelog_08.rst +++ b/doc/build/changelog/changelog_08.rst @@ -3,6 +3,16 @@ 0.8 Changelog ============== +.. changelog:: + :version: 0.8.2 + + .. change:: + :tags: bug, mysql + + Updated mysqlconnector dialect to check for disconnect based + on the apparent string message sent in the exception; tested + against mysqlconnector 1.0.9. + .. changelog:: :version: 0.8.1 :released: April 27, 2013 diff --git a/lib/sqlalchemy/dialects/mysql/mysqlconnector.py b/lib/sqlalchemy/dialects/mysql/mysqlconnector.py index 0a1a6b91e9..b1906d3b98 100644 --- a/lib/sqlalchemy/dialects/mysql/mysqlconnector.py +++ b/lib/sqlalchemy/dialects/mysql/mysqlconnector.py @@ -113,7 +113,8 @@ class MySQLDialect_mysqlconnector(MySQLDialect): errnos = (2006, 2013, 2014, 2045, 2055, 2048) exceptions = (self.dbapi.OperationalError, self.dbapi.InterfaceError) if isinstance(e, exceptions): - return e.errno in errnos + return e.errno in errnos or \ + "MySQL Connection not available." in str(e) else: return False diff --git a/test/engine/test_reconnect.py b/test/engine/test_reconnect.py index 9aecb81a99..b176c05ea1 100644 --- a/test/engine/test_reconnect.py +++ b/test/engine/test_reconnect.py @@ -617,19 +617,12 @@ class InvalidateDuringResultTest(fixtures.TestBase): meta.drop_all() engine.dispose() - @testing.fails_on('+cymysql', - "Buffers the result set and doesn't check for " - "connection close") - @testing.fails_on('+pymysql', - "Buffers the result set and doesn't check for " - "connection close") - @testing.fails_on('+mysqldb', - "Buffers the result set and doesn't check for " - "connection close") - @testing.fails_on('+pg8000', - "Buffers the result set and doesn't check for " - "connection close") - @testing.fails_on('+informixdb', + @testing.fails_if([ + '+mysqlconnector', '+mysqldb' + '+cymysql', '+pymysql', '+pg8000' + ], "Buffers the result set and doesn't check for " + "connection close") + @testing.fails_if('+informixdb', "Wrong error thrown, fix in informixdb?") def test_invalidate_on_results(self): conn = engine.connect()