Skip to content

Commit

Permalink
[3.2.x] Fixed collation tests on MySQL 8.0.30+.
Browse files Browse the repository at this point in the history
The utf8_ collations are renamed to utf8mb3_* on MySQL 8.0.30+.

Backport of 88dba2e from main.
  • Loading branch information
felixxm committed Aug 1, 2022
1 parent 840d009 commit cb7fbac
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions django/db/backends/mysql/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,15 @@ class DatabaseFeatures(BaseDatabaseFeatures):
@cached_property
def test_collations(self):
charset = 'utf8'
if self.connection.mysql_is_mariadb and self.connection.mysql_version >= (10, 6):
# utf8 is an alias for utf8mb3 in MariaDB 10.6+.
charset = 'utf8mb3'
if (
self.connection.mysql_is_mariadb
and self.connection.mysql_version >= (10, 6)
) or (
not self.connection.mysql_is_mariadb
and self.connection.mysql_version >= (8, 0, 30)
):
# utf8 is an alias for utf8mb3 in MariaDB 10.6+ and MySQL 8.0.30+.
charset = "utf8mb3"
return {
'ci': f'{charset}_general_ci',
'non_default': f'{charset}_esperanto_ci',
Expand Down

0 comments on commit cb7fbac

Please sign in to comment.