]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Catch DBAPIError instead of ProgrammingError for pyodbc fail
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 7 Oct 2016 13:16:22 +0000 (09:16 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 7 Oct 2016 13:17:46 +0000 (09:17 -0400)
Change-Id: Ide9e916d02fbbef549aa2838d1402c2b091e701d
Fixes: #3820
doc/build/changelog/changelog_11.rst
lib/sqlalchemy/dialects/mssql/pyodbc.py

index f4acf4924de51a9f4b8955fc018b439848b3a9d0..4b4c5204becf079ef6c52237a40782bd814eadd3 100644 (file)
 .. 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
index 30db94e49dcacc32796686497588f2e7f74b276d..5c6dd4cde253d1bb44f5badf9925e4b36fb8d001 100644 (file)
@@ -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: