summaryrefslogtreecommitdiff
path: root/django/db/backends/mysql/features.py
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2021-07-07 17:02:20 +0200
committerGitHub <noreply@github.com>2021-07-07 17:02:20 +0200
commit355ecd141671e34853d1ff99ffdb1a7fb95b4276 (patch)
tree9934f85c4ca7a8347cbf769329906b1b75ac6771 /django/db/backends/mysql/features.py
parentcf6774a53b40243d35183b4300a9385b68fd8c75 (diff)
downloaddjango-355ecd141671e34853d1ff99ffdb1a7fb95b4276.tar.gz
Fixed inspectdb and schema tests on MariaDB 10.6+.
The utf8 character set (and related collations) is by default an alias for utf8mb3 on MariaDB 10.6+.
Diffstat (limited to 'django/db/backends/mysql/features.py')
-rw-r--r--django/db/backends/mysql/features.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/django/db/backends/mysql/features.py b/django/db/backends/mysql/features.py
index eb80b2e543..f33ed0086b 100644
--- a/django/db/backends/mysql/features.py
+++ b/django/db/backends/mysql/features.py
@@ -47,11 +47,18 @@ class DatabaseFeatures(BaseDatabaseFeatures):
supports_order_by_nulls_modifier = False
order_by_nulls_first = True
- test_collations = {
- 'ci': 'utf8_general_ci',
- 'non_default': 'utf8_esperanto_ci',
- 'swedish_ci': 'utf8_swedish_ci',
- }
+
+ @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'
+ return {
+ 'ci': f'{charset}_general_ci',
+ 'non_default': f'{charset}_esperanto_ci',
+ 'swedish_ci': f'{charset}_swedish_ci',
+ }
@cached_property
def django_test_skips(self):