Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MNT Update Utf8TestHelper for MySQL 8.0.30 #10426

Merged
merged 1 commit into from
Jul 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 26 additions & 2 deletions tests/php/ORM/Utf8/Utf8TestHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ public function getUpdatedUtfCharsetForCurrentDB(string $charset): string
public function getUpdatedUtfCollationForCurrentDB(string $collation): string
{
if ($collation === 'utf8_general_ci') {
return $this->isMariaDBGte106() ? 'utf8mb3_general_ci' : 'utf8_general_ci';
return $this->isMariaDBGte106() || $this->isMySqlGte8030()
? 'utf8mb3_general_ci' : 'utf8_general_ci';
}
if ($collation === 'utf8_unicode_520_ci') {
return $this->isMariaDBGte106() ? 'utf8mb3_unicode_520_ci' : 'utf8_unicode_520_ci';
return $this->isMariaDBGte106() || $this->isMySqlGte8030()
? 'utf8mb3_unicode_520_ci' : 'utf8_unicode_520_ci';
}
return $collation;
}
Expand All @@ -45,6 +47,28 @@ private function isMySqlGte80(): bool
return false;
}

/**
* Starting with 8.0.30, utf8mb3 is reported for the collation as well
* https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-30.html
*/
private function isMySqlGte8030(): bool
{
// Example MySQL version: 8.0.29
if (preg_match('#^([0-9]+)\.([0-9]+)\.([0-9]+)$#', $this->getDBVersion(), $m)) {
if ((int) $m[1] >= 8) {
if ((int) $m[2] === 0) {
if ((int) $m[3] >= 30) {
return true;
}
} else {
return true;
}
emteknetnz marked this conversation as resolved.
Show resolved Hide resolved
}
}
return false;
}


/**
* Until MariaDB 10.5, utf8mb3 was an alias for utf8.
* From MariaDB 10.6, utf8 is by default an alias for utf8mb3
Expand Down