]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Fixed the version string detection in the pymssql dialect to
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 16 Sep 2014 21:40:06 +0000 (17:40 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 16 Sep 2014 21:41:07 +0000 (17:41 -0400)
work with Microsoft SQL Azure, which changes the word "SQL Server"
to "SQL Azure".
fixes #3151

doc/build/changelog/changelog_09.rst
lib/sqlalchemy/dialects/mssql/pymssql.py
test/dialect/mssql/test_engine.py

index 329e054b08316300d7a43c3a489beb04c700b98d..91e66bded3b6eab17c190e262f71312197ad9286 100644 (file)
 .. changelog::
     :version: 0.9.8
 
+    .. change::
+        :tags: bug, mssql
+        :versions: 1.0.0
+        :tickets: 3151
+
+        Fixed the version string detection in the pymssql dialect to
+        work with Microsoft SQL Azure, which changes the word "SQL Server"
+        to "SQL Azure".
+
     .. change::
         :tags: bug, orm
         :versions: 1.0.0
index 8f76336aeb58b2d64a658ea2dd50182885ea0a1c..b5a1bc5666f6678b1bc37599b8b6fc2bb264765c 100644 (file)
@@ -63,7 +63,7 @@ class MSDialect_pymssql(MSDialect):
     def _get_server_version_info(self, connection):
         vers = connection.scalar("select @@version")
         m = re.match(
-            r"Microsoft SQL Server.*? - (\d+).(\d+).(\d+).(\d+)", vers)
+            r"Microsoft .*? - (\d+).(\d+).(\d+).(\d+)", vers)
         if m:
             return tuple(int(x) for x in m.group(1, 2, 3, 4))
         else:
index c07f30040515941e21cfd3cf0b26db827722b085..f7022030fa7d56ca72d4ea7834e10aac5a5e2e8f 100644 (file)
@@ -7,6 +7,8 @@ from sqlalchemy.engine import url
 from sqlalchemy.testing import fixtures
 from sqlalchemy import testing
 from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing.mock import Mock
+
 
 class ParseConnectTest(fixtures.TestBase):
 
@@ -153,3 +155,21 @@ class ParseConnectTest(fixtures.TestBase):
         assert_raises_message(exc.SAWarning,
                               'Unrecognized server version info',
                               engine.connect)
+
+
+class VersionDetectionTest(fixtures.TestBase):
+    def test_pymssql_version(self):
+        dialect = pymssql.MSDialect_pymssql()
+
+        for vers in [
+            "Microsoft SQL Server Blah - 11.0.9216.62",
+            "Microsoft SQL Server (XYZ) - 11.0.9216.62 \n"
+            "Jul 18 2014 22:00:21 \nCopyright (c) Microsoft Corporation",
+            "Microsoft SQL Azure (RTM) - 11.0.9216.62 \n"
+            "Jul 18 2014 22:00:21 \nCopyright (c) Microsoft Corporation"
+        ]:
+            conn = Mock(scalar=Mock(return_value=vers))
+            eq_(
+                dialect._get_server_version_info(conn),
+                (11, 0, 9216, 62)
+            )