From: Mike Bayer Date: Sun, 22 Mar 2015 23:05:22 +0000 (-0400) Subject: - Fixed unicode support for PyMySQL when using an "executemany" X-Git-Tag: rel_1_0_0b4~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=db853306c40437a8ad3dc9f510865820a941c3b5;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - Fixed unicode support for PyMySQL when using an "executemany" operation with unicode parameters. SQLAlchemy now passes both the statement as well as the bound parameters as unicode objects, as PyMySQL generally uses string interpolation internally to produce the final statement, and in the case of executemany does the "encode" step only on the final statement. fixes #3337 --- diff --git a/doc/build/changelog/changelog_09.rst b/doc/build/changelog/changelog_09.rst index 3c38de4549..53c4eeaaab 100644 --- a/doc/build/changelog/changelog_09.rst +++ b/doc/build/changelog/changelog_09.rst @@ -14,6 +14,18 @@ .. changelog:: :version: 0.9.10 + .. change:: + :tags: bug, mysql, pymysql + :tickets: 3337 + :versions: 1.0.0b4 + + Fixed unicode support for PyMySQL when using an "executemany" + operation with unicode parameters. SQLAlchemy now passes both + the statement as well as the bound parameters as unicode + objects, as PyMySQL generally uses string interpolation + internally to produce the final statement, and in the case of + executemany does the "encode" step only on the final statement. + .. change:: :tags: bug, py3k, mysql :tickets: 3333 diff --git a/lib/sqlalchemy/dialects/mysql/pymysql.py b/lib/sqlalchemy/dialects/mysql/pymysql.py index 92aaf89af8..87159b5613 100644 --- a/lib/sqlalchemy/dialects/mysql/pymysql.py +++ b/lib/sqlalchemy/dialects/mysql/pymysql.py @@ -37,7 +37,12 @@ class MySQLDialect_pymysql(MySQLDialect_mysqldb): driver = 'pymysql' description_encoding = None + + # generally, these two values should be both True + # or both False. PyMySQL unicode tests pass all the way back + # to 0.4 either way. See [ticket:3337] supports_unicode_statements = True + supports_unicode_binds = True @classmethod def dbapi(cls): diff --git a/test/sql/test_types.py b/test/sql/test_types.py index 8b353c0491..1fac13b05a 100644 --- a/test/sql/test_types.py +++ b/test/sql/test_types.py @@ -972,6 +972,7 @@ class UnicodeTest(fixtures.TestBase): ('postgresql', 'pypostgresql'), ('postgresql', 'pg8000'), ('postgresql', 'zxjdbc'), + ('mysql', 'pymysql'), ('mysql', 'oursql'), ('mysql', 'zxjdbc'), ('mysql', 'mysqlconnector'),