From 3757c0cdfb1c5078c8829abe3f6a995126de8ce6 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 26 Jan 2017 16:54:02 -0500 Subject: [PATCH] Don't check isolation level prior to SQL Server 2005 Added a version check to the "get_isolation_level" feature, which is invoked upon first connect, so that it skips for SQL Server version 2000, as the necessary system view is not available prior to SQL Server 2005. Change-Id: If4f860513f0aae6625803f449714aedfc5075f57 Fixes: #3898 --- doc/build/changelog/changelog_11.rst | 9 +++++++++ lib/sqlalchemy/dialects/mssql/base.py | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/doc/build/changelog/changelog_11.rst b/doc/build/changelog/changelog_11.rst index a969d616fd..33eca2eca6 100644 --- a/doc/build/changelog/changelog_11.rst +++ b/doc/build/changelog/changelog_11.rst @@ -21,6 +21,15 @@ .. changelog:: :version: 1.1.6 + .. change:: 3898 + :tags: bug, mssql + :tickets: 3898 + + Added a version check to the "get_isolation_level" feature, which is + invoked upon first connect, so that it skips for SQL Server version + 2000, as the necessary system view is not available prior to SQL Server + 2005. + .. change:: 3893 :tags: bug, orm :tickets: 3893 diff --git a/lib/sqlalchemy/dialects/mssql/base.py b/lib/sqlalchemy/dialects/mssql/base.py index 3e16e6e35c..6975754c63 100644 --- a/lib/sqlalchemy/dialects/mssql/base.py +++ b/lib/sqlalchemy/dialects/mssql/base.py @@ -1685,6 +1685,10 @@ class MSDialect(default.DefaultDialect): cursor.close() def get_isolation_level(self, connection): + if self.server_version_info < MS_2005_VERSION: + raise NotImplementedError( + "Can't fetch isolation level prior to SQL Server 2005") + cursor = connection.cursor() cursor.execute(""" SELECT CASE transaction_isolation_level -- 2.47.3