diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-12-16 17:02:48 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-12-16 17:02:48 -0500 |
commit | 00aaaa4bd4aa150ff9964bf2c00b1404d2e8a140 (patch) | |
tree | 5fa2259437d22527f03a81c45505eaeea202315b | |
parent | d5f88ee9e51ceeaf4705d3b456b33b779cf25a5c (diff) | |
download | sqlalchemy-00aaaa4bd4aa150ff9964bf2c00b1404d2e8a140.tar.gz |
- 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
-rw-r--r-- | doc/build/changelog/changelog_09.rst | 8 | ||||
-rw-r--r-- | lib/sqlalchemy/dialects/mysql/mysqldb.py | 13 |
2 files changed, 15 insertions, 6 deletions
diff --git a/doc/build/changelog/changelog_09.rst b/doc/build/changelog/changelog_09.rst index 419827959..b2c876141 100644 --- a/doc/build/changelog/changelog_09.rst +++ b/doc/build/changelog/changelog_09.rst @@ -14,6 +14,14 @@ :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 893c6a9e2..5bb67a24d 100644 --- a/lib/sqlalchemy/dialects/mysql/mysqldb.py +++ b/lib/sqlalchemy/dialects/mysql/mysqldb.py @@ -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( |