diff options
author | Gord Thompson <gord@gordthompson.com> | 2020-05-29 07:20:54 -0600 |
---|---|---|
committer | Gord Thompson <gord@gordthompson.com> | 2020-06-01 06:02:20 -0600 |
commit | ddff320473dcbd3cc11d577715f96237276bc685 (patch) | |
tree | 541871384a1bc58a52d3c6127c79744567293f93 /lib | |
parent | cbfa1363d7201848a56e7209146e81b9c51aa8af (diff) | |
download | sqlalchemy-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.py | 6 |
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 ) |