From cb7fbac9f8a93d730be66815620d5769aad521bc Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Wed, 27 Jul 2022 21:36:25 +0200 Subject: [PATCH] [3.2.x] Fixed collation tests on MySQL 8.0.30+. The utf8_ collations are renamed to utf8mb3_* on MySQL 8.0.30+. Backport of 88dba2e3fd64b64bcf4fae83b256b4f6f492558f from main. --- django/db/backends/mysql/features.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/django/db/backends/mysql/features.py b/django/db/backends/mysql/features.py index a37fe81cbd..1a9f5da39e 100644 --- a/django/db/backends/mysql/features.py +++ b/django/db/backends/mysql/features.py @@ -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',