1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Fixed DatabaseFeatures.supports_index_column_ordering and related tests with MyISAM storage engine.

This commit is contained in:
Mariusz Felisiak 2022-04-12 15:34:26 +02:00
parent 1bdfde0857
commit fdfb3086fc
3 changed files with 7 additions and 0 deletions

View File

@ -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)

View File

@ -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,

View File

@ -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()