summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-07-13 20:52:05 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2010-07-13 20:52:05 -0400
commit85a800680a800c945ce9a888c8c8891ba700197a (patch)
tree964eb73deeb2807ef687c5d39b333eb5a1951f7b
parentccafaab2003a8aebc1f8f7fd42d464d94649563a (diff)
downloadsqlalchemy-85a800680a800c945ce9a888c8c8891ba700197a.tar.gz
- _extract_error_code now expects the raw DBAPI error in all cases
for all four MySQL dialects. has_table() passes in the "orig" from the SQLAlchemy exception. continuing of [ticket:1848]
-rw-r--r--CHANGES12
-rw-r--r--lib/sqlalchemy/dialects/mysql/base.py13
-rw-r--r--lib/sqlalchemy/dialects/mysql/mysqlconnector.py5
-rw-r--r--lib/sqlalchemy/dialects/mysql/mysqldb.py7
-rw-r--r--lib/sqlalchemy/dialects/mysql/oursql.py5
-rw-r--r--lib/sqlalchemy/dialects/mysql/pyodbc.py2
6 files changed, 19 insertions, 25 deletions
diff --git a/CHANGES b/CHANGES
index 082ec8382..ac180b0f0 100644
--- a/CHANGES
+++ b/CHANGES
@@ -29,12 +29,14 @@ CHANGES
- mysql
- The _extract_error_code() method now works
- correctly with the "mysqldb" dialect. Previously,
+ correctly with each MySQL dialect (
+ MySQL-python, OurSQL, MySQL-Connector-Python,
+ PyODBC). 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]
+ conditions, however since MySQLdb and OurSQL
+ have their own reconnect feature, there was no
+ symptom for these drivers here unless one
+ watched the logs. [ticket:1848]
0.6.2
=====
diff --git a/lib/sqlalchemy/dialects/mysql/base.py b/lib/sqlalchemy/dialects/mysql/base.py
index 46e29694f..af18ae551 100644
--- a/lib/sqlalchemy/dialects/mysql/base.py
+++ b/lib/sqlalchemy/dialects/mysql/base.py
@@ -1708,8 +1708,11 @@ class MySQLDialect(default.DefaultDialect):
def is_disconnect(self, e):
if isinstance(e, self.dbapi.OperationalError):
- return self._extract_error_code(e) in (2006, 2013, 2014, 2045, 2055)
- elif isinstance(e, self.dbapi.InterfaceError): # if underlying connection is closed, this is the error you get
+ return self._extract_error_code(e) in \
+ (2006, 2013, 2014, 2045, 2055)
+ elif isinstance(e, self.dbapi.InterfaceError):
+ # if underlying connection is closed,
+ # this is the error you get
return "(0, '')" in str(e)
else:
return False
@@ -1760,7 +1763,7 @@ class MySQLDialect(default.DefaultDialect):
rs.close()
return have
except exc.SQLError, e:
- if self._extract_error_code(e) == 1146:
+ if self._extract_error_code(e.orig) == 1146:
return False
raise
finally:
@@ -2048,7 +2051,7 @@ class MySQLDialect(default.DefaultDialect):
try:
rp = connection.execute(st)
except exc.SQLError, e:
- if self._extract_error_code(e) == 1146:
+ if self._extract_error_code(e.orig) == 1146:
raise exc.NoSuchTableError(full_name)
else:
raise
@@ -2072,7 +2075,7 @@ class MySQLDialect(default.DefaultDialect):
try:
rp = connection.execute(st)
except exc.SQLError, e:
- if self._extract_error_code(e) == 1146:
+ if self._extract_error_code(e.orig) == 1146:
raise exc.NoSuchTableError(full_name)
else:
raise
diff --git a/lib/sqlalchemy/dialects/mysql/mysqlconnector.py b/lib/sqlalchemy/dialects/mysql/mysqlconnector.py
index 2da18e50f..bd9c9b8e2 100644
--- a/lib/sqlalchemy/dialects/mysql/mysqlconnector.py
+++ b/lib/sqlalchemy/dialects/mysql/mysqlconnector.py
@@ -110,10 +110,7 @@ class MySQLDialect_mysqlconnector(MySQLDialect):
return connection.connection.get_characterset_info()
def _extract_error_code(self, exception):
- try:
- return exception.orig.errno
- except AttributeError:
- return None
+ return exception.errno
def is_disconnect(self, e):
errnos = (2006, 2013, 2014, 2045, 2055, 2048)
diff --git a/lib/sqlalchemy/dialects/mysql/mysqldb.py b/lib/sqlalchemy/dialects/mysql/mysqldb.py
index d43b62ce3..54f10352f 100644
--- a/lib/sqlalchemy/dialects/mysql/mysqldb.py
+++ b/lib/sqlalchemy/dialects/mysql/mysqldb.py
@@ -156,12 +156,7 @@ class MySQLDialect_mysqldb(MySQLDialect):
return tuple(version)
def _extract_error_code(self, exception):
- try:
- return exception.args[0]
- except AttributeError:
- # this AttributeError is likely unnecessary,
- # but would need to confirm against MySQLdb code
- return None
+ return exception.args[0]
def _detect_charset(self, connection):
"""Sniff out the character set in use for connection results."""
diff --git a/lib/sqlalchemy/dialects/mysql/oursql.py b/lib/sqlalchemy/dialects/mysql/oursql.py
index ebc726482..41c5414f2 100644
--- a/lib/sqlalchemy/dialects/mysql/oursql.py
+++ b/lib/sqlalchemy/dialects/mysql/oursql.py
@@ -230,10 +230,7 @@ class MySQLDialect_oursql(MySQLDialect):
return tuple(version)
def _extract_error_code(self, exception):
- try:
- return exception.orig.errno
- except AttributeError:
- return None
+ return exception.errno
def _detect_charset(self, connection):
"""Sniff out the character set in use for connection results."""
diff --git a/lib/sqlalchemy/dialects/mysql/pyodbc.py b/lib/sqlalchemy/dialects/mysql/pyodbc.py
index 1f73c6ef1..eb7b23c07 100644
--- a/lib/sqlalchemy/dialects/mysql/pyodbc.py
+++ b/lib/sqlalchemy/dialects/mysql/pyodbc.py
@@ -66,7 +66,7 @@ class MySQLDialect_pyodbc(PyODBCConnector, MySQLDialect):
return 'latin1'
def _extract_error_code(self, exception):
- m = re.compile(r"\((\d+)\)").search(str(exception.orig.args))
+ m = re.compile(r"\((\d+)\)").search(str(exception.args))
c = m.group(1)
if c:
return int(c)