]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- pymssql has PEP249 Binary contructor since 2.1.1
authorRamiro Morales <ramiro@rmorales.net>
Sun, 5 Apr 2015 22:14:54 +0000 (19:14 -0300)
committerRamiro Morales <ramiro@rmorales.net>
Sun, 5 Apr 2015 22:14:54 +0000 (19:14 -0300)
See https://github.com/pymssql/pymssql/commit/e7fb15dd29090e1f1bb570842b53aea1ec32d8f0

lib/sqlalchemy/dialects/mssql/pymssql.py

index 2214d18d1425c5010803118a9fcc0a38e2fc1b11..324b3770c22f2ca58fcbe653bcef0d9318fa1eb7 100644 (file)
@@ -46,11 +46,12 @@ class MSDialect_pymssql(MSDialect):
     @classmethod
     def dbapi(cls):
         module = __import__('pymssql')
-        # pymmsql doesn't have a Binary method.  we use string
-        # TODO: monkeypatching here is less than ideal
-        module.Binary = lambda x: x if hasattr(x, 'decode') else str(x)
-
+        # pymmsql < 2.1.1 doesn't have a Binary method.  we use string
         client_ver = tuple(int(x) for x in module.__version__.split("."))
+        if client_ver < (2, 1, 1):
+            # TODO: monkeypatching here is less than ideal
+            module.Binary = lambda x: x if hasattr(x, 'decode') else str(x)
+
         if client_ver < (1, ):
             util.warn("The pymssql dialect expects at least "
                       "the 1.0 series of the pymssql DBAPI.")