From: Mike Bayer Date: Tue, 16 Dec 2014 22:02:48 +0000 (-0500) Subject: - Added a version check to the MySQLdb dialect surrounding the X-Git-Tag: rel_0_9_9~60 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=10f855f3184a79d58950f4e5cb59b86c81d38fe5;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - Added a version check to the MySQLdb dialect surrounding the check for 'utf8_bin' collation, as this fails on MySQL server < 5.0. fixes #3274 (cherry picked from commit 00aaaa4bd4aa150ff9964bf2c00b1404d2e8a140) --- diff --git a/doc/build/changelog/changelog_09.rst b/doc/build/changelog/changelog_09.rst index 4198279594..b2c876141e 100644 --- a/doc/build/changelog/changelog_09.rst +++ b/doc/build/changelog/changelog_09.rst @@ -13,6 +13,14 @@ .. 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 diff --git a/lib/sqlalchemy/dialects/mysql/mysqldb.py b/lib/sqlalchemy/dialects/mysql/mysqldb.py index 7cb2e66128..77e2912a87 100644 --- a/lib/sqlalchemy/dialects/mysql/mysqldb.py +++ b/lib/sqlalchemy/dialects/mysql/mysqldb.py @@ -79,12 +79,13 @@ class MySQLDialect_mysqldb(MySQLDBConnector, 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(