From: Mike Bayer Date: Fri, 7 Oct 2016 13:16:22 +0000 (-0400) Subject: Catch DBAPIError instead of ProgrammingError for pyodbc fail X-Git-Tag: rel_1_1_1~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ae9300cac0ec398f92d9e523273403126a709134;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Catch DBAPIError instead of ProgrammingError for pyodbc fail Change-Id: Ide9e916d02fbbef549aa2838d1402c2b091e701d Fixes: #3820 --- diff --git a/doc/build/changelog/changelog_11.rst b/doc/build/changelog/changelog_11.rst index f4acf4924d..4b4c5204be 100644 --- a/doc/build/changelog/changelog_11.rst +++ b/doc/build/changelog/changelog_11.rst @@ -21,6 +21,17 @@ .. changelog:: :version: 1.1.1 + .. change:: + :tags: bug, mssql + :tickets: 3820 + + The "SELECT SERVERPROPERTY" + query added in :ticket:`3810` and :ticket:`3814` is failing on unknown + combinations of Pyodbc and SQL Server. While failure of this function + was anticipated, the exception catch was not broad enough so it now + catches all forms of pyodbc.Error. + + .. changelog:: :version: 1.1.0 :released: October 5, 2016 diff --git a/lib/sqlalchemy/dialects/mssql/pyodbc.py b/lib/sqlalchemy/dialects/mssql/pyodbc.py index 30db94e49d..5c6dd4cde2 100644 --- a/lib/sqlalchemy/dialects/mssql/pyodbc.py +++ b/lib/sqlalchemy/dialects/mssql/pyodbc.py @@ -273,9 +273,10 @@ class MSDialect_pyodbc(PyODBCConnector, MSDialect): def _get_server_version_info(self, connection): try: raw = connection.scalar("SELECT SERVERPROPERTY('ProductVersion')") - except exc.ProgrammingError: + except exc.DBAPIError: # SQL Server docs indicate this function isn't present prior to - # 2008 + # 2008; additionally, unknown combinations of pyodbc aren't + # able to run this query. return super(MSDialect_pyodbc, self).\ _get_server_version_info(connection) else: