summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGord Thompson <gord@gordthompson.com>2020-05-29 07:20:54 -0600
committerGord Thompson <gord@gordthompson.com>2020-06-01 06:02:20 -0600
commitddff320473dcbd3cc11d577715f96237276bc685 (patch)
tree541871384a1bc58a52d3c6127c79744567293f93 /lib
parentcbfa1363d7201848a56e7209146e81b9c51aa8af (diff)
downloadsqlalchemy-ddff320473dcbd3cc11d577715f96237276bc685.tar.gz
Fix is_disconnect false positive for mssql+pyodbc
Fixed an issue where the ``is_disconnect`` function in the SQL Server pyodbc dialect was incorrectly reporting the disconnect state when the exception messsage had a substring that matched a SQL Server ODBC error code. Fixes: #5359 Change-Id: I450c6818405a20f4daee20d58fce2d5ecb33e17f
Diffstat (limited to 'lib')
-rw-r--r--lib/sqlalchemy/dialects/mssql/pyodbc.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/sqlalchemy/dialects/mssql/pyodbc.py b/lib/sqlalchemy/dialects/mssql/pyodbc.py
index ff164e886..6cf45e7b8 100644
--- a/lib/sqlalchemy/dialects/mssql/pyodbc.py
+++ b/lib/sqlalchemy/dialects/mssql/pyodbc.py
@@ -419,7 +419,8 @@ class MSDialect_pyodbc(PyODBCConnector, MSDialect):
def is_disconnect(self, e, connection, cursor):
if isinstance(e, self.dbapi.Error):
- for code in (
+ code = e.args[0]
+ if code in (
"08S01",
"01002",
"08003",
@@ -430,8 +431,7 @@ class MSDialect_pyodbc(PyODBCConnector, MSDialect):
"HY010",
"10054",
):
- if code in str(e):
- return True
+ return True
return super(MSDialect_pyodbc, self).is_disconnect(
e, connection, cursor
)