]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Emit SET NAMES for all MySQL connections w charset
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 11 Aug 2019 21:42:59 +0000 (17:42 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 11 Aug 2019 23:16:53 +0000 (19:16 -0400)
commitd890ce67d877fa2b6a20bbda084eb6c21d166ae7
treef840b4aa4926a998655f103c935047160b95490f
parent9d6f9f73982e374a5e56f5440e23ec7d8602dd74
Emit SET NAMES for all MySQL connections w charset

The MySQL dialects will emit "SET NAMES" at the start of a connection when
charset is given to the MySQL driver, to appease an apparent behavior
observed in MySQL 8.0 that raises a collation error when a UNION includes
string columns unioned against columns of the form CAST(NULL AS CHAR(..)),
which is what SQLAlchemy's polymorphic_union function does.   The issue
seems to have affected PyMySQL for at least a year, however has recently
appeared as of mysqlclient 1.4.4 based on changes in how this DBAPI creates
a connection.  As the presence of this directive impacts three separate
MySQL charset settings which each have intricate effects based on their
presense,  SQLAlchemy will now emit the directive on new connections to
ensure correct behavior.

Fixes: #4804
Change-Id: If9d7ee00d0ccaf773972b564fe455e8e9edf6627
(cherry picked from commit f5e57f7c311288d892894edcc44d901b5bfbb3d1)
doc/build/changelog/unreleased_13/4804.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/mysql/mysqldb.py
lib/sqlalchemy/testing/suite/test_types.py
test/profiles.txt