summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--django/db/backends/mysql/features.py2
-rw-r--r--django/db/models/indexes.py4
-rw-r--r--tests/indexes/tests.py1
3 files changed, 7 insertions, 0 deletions
diff --git a/django/db/backends/mysql/features.py b/django/db/backends/mysql/features.py
index c4706fc1b0..a34741267a 100644
--- a/django/db/backends/mysql/features.py
+++ b/django/db/backends/mysql/features.py
@@ -328,6 +328,8 @@ class DatabaseFeatures(BaseDatabaseFeatures):
@cached_property
def supports_index_column_ordering(self):
+ if self._mysql_storage_engine != "InnoDB":
+ return False
if self.connection.mysql_is_mariadb:
return self.connection.mysql_version >= (10, 8)
return self.connection.mysql_version >= (8, 0, 1)
diff --git a/django/db/models/indexes.py b/django/db/models/indexes.py
index 3c2b699ccc..71976c4fdd 100644
--- a/django/db/models/indexes.py
+++ b/django/db/models/indexes.py
@@ -111,6 +111,10 @@ class Index:
for field_name, _ in self.fields_orders
]
col_suffixes = [order[1] for order in self.fields_orders]
+ if schema_editor.connection.features.supports_index_column_ordering:
+ col_suffixes = [order[1] for order in self.fields_orders]
+ else:
+ col_suffixes = [""] * len(self.fields_orders)
expressions = None
return schema_editor._create_index_sql(
model,
diff --git a/tests/indexes/tests.py b/tests/indexes/tests.py
index 7bc305e596..b5cdef3545 100644
--- a/tests/indexes/tests.py
+++ b/tests/indexes/tests.py
@@ -93,6 +93,7 @@ class SchemaIndexesTests(TestCase):
str(index.create_sql(Article, editor)),
)
+ @skipUnlessDBFeature("supports_index_column_ordering")
def test_descending_columns_list_sql(self):
index = Index(fields=["-headline"], name="whitespace_idx")
editor = connection.schema_editor()