DbConnection: Set `COLLATE 'latin1_general_ci'` for `latin1` charsets

MySQL 8+ seems a bit more strict now.
This commit is contained in:
Johannes Meyer 2019-12-05 13:45:25 +01:00
parent 51b05ce39a
commit d0857345d0
1 changed files with 7 additions and 0 deletions

View File

@ -205,8 +205,15 @@ class DbConnection implements Selectable, Extensible, Updatable, Reducible, Insp
. 'ANSI_QUOTES,PIPES_AS_CONCAT,NO_ENGINE_SUBSTITUTION\'';
if (isset($adapterParamaters['charset'])) {
$driverOptions[PDO::MYSQL_ATTR_INIT_COMMAND] .= ', NAMES ' . $adapterParamaters['charset'];
if (trim($adapterParamaters['charset']) === 'latin1') {
// Required for MySQL 8+ because we need PIPES_AS_CONCAT and
// have several columns with explicit COLLATE instructions
$driverOptions[PDO::MYSQL_ATTR_INIT_COMMAND] .= ' COLLATE latin1_general_ci';
}
unset($adapterParamaters['charset']);
}
$driverOptions[PDO::MYSQL_ATTR_INIT_COMMAND] .= ", time_zone='" . $this->defaultTimezoneOffset() . "'";
$driverOptions[PDO::MYSQL_ATTR_INIT_COMMAND] .=';';
$defaultPort = 3306;