From 800448ad621a7cbe50726b6e208f55264dc623bc Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 12 Jul 2010 11:15:16 -0400 Subject: [PATCH] - The _extract_error_code() method now works correctly with the "mysqldb" dialect. Previously, the reconnect logic would fail for OperationalError conditions, however since MySQLdb has its own reconnect feature, there was no symptom here unless one watched the logs. [ticket:1848] --- CHANGES | 10 ++++++++++ lib/sqlalchemy/dialects/mysql/mysqldb.py | 4 +++- lib/sqlalchemy/test/engines.py | 5 +++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 83ed69118b..082ec83822 100644 --- a/CHANGES +++ b/CHANGES @@ -25,6 +25,16 @@ CHANGES naming/typing information about the entities the Query will return. Can be helpful for building GUIs on top of ORM queries. + +- mysql + + - The _extract_error_code() method now works + correctly with the "mysqldb" dialect. Previously, + the reconnect logic would fail for OperationalError + conditions, however since MySQLdb has its + own reconnect feature, there was no symptom + here unless one watched the logs. + [ticket:1848] 0.6.2 ===== diff --git a/lib/sqlalchemy/dialects/mysql/mysqldb.py b/lib/sqlalchemy/dialects/mysql/mysqldb.py index 6e6bb0ecc6..d43b62ce3d 100644 --- a/lib/sqlalchemy/dialects/mysql/mysqldb.py +++ b/lib/sqlalchemy/dialects/mysql/mysqldb.py @@ -157,8 +157,10 @@ class MySQLDialect_mysqldb(MySQLDialect): def _extract_error_code(self, exception): try: - return exception.orig.args[0] + return exception.args[0] except AttributeError: + # this AttributeError is likely unnecessary, + # but would need to confirm against MySQLdb code return None def _detect_charset(self, connection): diff --git a/lib/sqlalchemy/test/engines.py b/lib/sqlalchemy/test/engines.py index 0cfd58d207..9e77f38d71 100644 --- a/lib/sqlalchemy/test/engines.py +++ b/lib/sqlalchemy/test/engines.py @@ -105,6 +105,11 @@ class ReconnectFixture(object): return conn def shutdown(self): + # TODO: this doesn't cover all cases + # as nicely as we'd like, namely MySQLdb. + # would need to implement R. Brewer's + # proxy server idea to get better + # coverage. for c in list(self.connections): c.close() self.connections = [] -- 2.47.2