Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move MYSQL_ENABLE_UTF8 to a connection-level attribute
When MYSQL_ENABLE_UTF8 is set, it currently does not provide the mysql_enable_utf8 parameter to the DBI->connect call; instead it's part of the DBI handle attributes that get set on an already-created handle. From the docs for DBD::mysql, mysql_enable_utf8 needs to be set on connect, otherwise there are additional steps one needs to take to get the results returned in UTF8 (primarily issuing a $dbh->do("SET NAMES utf8") on the opened handle). With this change, when the catalog.cfg defines MYSQL_ENABLE_UTF8, the mysql_enable_utf8 => 1 attribute will be included in the hash of options returned by Vend::Table::DBI::find_dsn. This will not occur unless said DatabaseDefault/Database attribute is defined. This corrects a bug when using MySQL with MV_UTF8 mode, as with the old behavior the UTF8 flag would be set on the values returned from the database, but they would not have been transferred in UTF8, but instead with the server's default character set (likely latin1). The normal way to get around this issue when setting the $dbh attribute manually is to issue a $dbh->do("SET NAMES utf8"), which has the effect of setting the client's connection and results character sets to UTF8. This has the possibility of introducing some changes in application behavior, but since MYSQL_ENABLE_UTF8 is generally turned on in conjunction with MV_UTF8 mode, this is not judged to be a big risk. If existing user code was already working around this bug by issuing its own $dbh->do("SET NAMES utf8"), this will continue to work, essentially becoming a no-op.
- Loading branch information