]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Enable decimal implicit bind for mysqlclient, is fixed as of
authorMike Bayer <mike_mp@zzzcomputing.com>
Sat, 20 Oct 2018 16:32:25 +0000 (12:32 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 20 Oct 2018 16:32:25 +0000 (12:32 -0400)
post 1.3.13

Change-Id: Ic7a2055597d06038ab330f1114416e4538964a2b

lib/sqlalchemy/dialects/mysql/mysqldb.py
test/requirements.py

index 7554d244cc46e9ca2bea7ef9124502200f12b996..837dce5b77c909aa6f53845c559ff982c24b224a 100644 (file)
@@ -87,6 +87,18 @@ class MySQLDialect_mysqldb(MySQLDialect):
     def __init__(self, server_side_cursors=False, **kwargs):
         super(MySQLDialect_mysqldb, self).__init__(**kwargs)
         self.server_side_cursors = server_side_cursors
+        self._mysql_dbapi_version = self._parse_dbapi_version(
+            self.dbapi.__version__)
+
+    def _parse_dbapi_version(self, version):
+        m = re.match(r'(\d+)\.(\d+)(?:\.(\d+))?', version)
+        if m:
+            return tuple(
+                int(x)
+                for x in m.group(1, 2, 3)
+                if x is not None)
+        else:
+            return (0, 0, 0)
 
     @util.langhelpers.memoized_property
     def supports_server_side_cursors(self):
index 1cf40d8a4f2916be660cbe3a8178f2e98995af71..9afabc512def10cc8d98dde22955b2dac8855f85 100644 (file)
@@ -945,7 +945,21 @@ class DefaultRequirements(SuiteRequirements):
 
         """
 
-        return exclusions.fails_on("mysql+mysqldb", "driver specific")
+        # fixed for mysqlclient in
+        # https://github.com/PyMySQL/mysqlclient-python/commit/68b9662918577fc05be9610ef4824a00f2b051b0
+        def check(config):
+            if against(config, "mysql+mysqldb"):
+                # can remove once post 1.3.13 is released
+                try:
+                    from MySQLdb import converters
+                    from decimal import Decimal
+                    return Decimal not in converters.conversions
+                except:
+                    return True
+
+            return against(config, "mysql+mysqldb") and \
+                config.db.dialect._mysql_dbapi_version <= (1, 3, 13)
+        return exclusions.fails_on(check, "fixed for mysqlclient post 1.3.13")
 
     @property
     def fetch_null_from_numeric(self):