]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Added a version check to the MySQLdb dialect surrounding the
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 16 Dec 2014 22:02:48 +0000 (17:02 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 16 Dec 2014 22:02:48 +0000 (17:02 -0500)
check for 'utf8_bin' collation, as this fails on MySQL server < 5.0.
fixes #3274

doc/build/changelog/changelog_09.rst
lib/sqlalchemy/dialects/mysql/mysqldb.py

index 4198279594ccf9cd874118326a263ca5d6931079..b2c876141ee886d5bcaf97560eaf4e0ee86520ca 100644 (file)
 .. changelog::
     :version: 0.9.9
 
+    .. change::
+        :tags: bug, mysql
+        :versions: 1.0.0
+        :tickets: 3274
+
+        Added a version check to the MySQLdb dialect surrounding the
+        check for 'utf8_bin' collation, as this fails on MySQL server < 5.0.
+
     .. change::
         :tags: enhancement, orm
         :versions: 1.0.0
index 893c6a9e2ee3ceb8dfe7cd8077156d8314ee86d3..5bb67a24d35b806baaf9c4abd852d2567ad4b983 100644 (file)
@@ -102,12 +102,13 @@ class MySQLDialect_mysqldb(MySQLDialect):
         # https://github.com/farcepest/MySQLdb1/commit/cd44524fef63bd3fcb71947392326e9742d520e8
         # specific issue w/ the utf8_bin collation and unicode returns
 
-        has_utf8_bin = connection.scalar(
-            "show collation where %s = 'utf8' and %s = 'utf8_bin'"
-            % (
-                self.identifier_preparer.quote("Charset"),
-                self.identifier_preparer.quote("Collation")
-            ))
+        has_utf8_bin = self.server_version_info > (5, ) and \
+            connection.scalar(
+                "show collation where %s = 'utf8' and %s = 'utf8_bin'"
+                % (
+                    self.identifier_preparer.quote("Charset"),
+                    self.identifier_preparer.quote("Collation")
+                ))
         if has_utf8_bin:
             additional_tests = [
                 sql.collate(sql.cast(