mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #26171 -- Made MySQL create an index on ForeignKeys with db_contraint=False.
Refactored "Prevented unneeded index creation on MySQL-InnoDB" (2ceb10f)
to avoid setting db_index=False.
This commit is contained in:
committed by
Tim Graham
parent
5fe1c92250
commit
6bf7964023
@@ -62,7 +62,7 @@ class SchemaIndexesTests(TestCase):
|
||||
def test_no_index_for_foreignkey(self):
|
||||
"""
|
||||
MySQL on InnoDB already creates indexes automatically for foreign keys.
|
||||
(#14180).
|
||||
(#14180). An index should be created if db_constraint=False (#26171).
|
||||
"""
|
||||
storage = connection.introspection.get_storage_engine(
|
||||
connection.cursor(), ArticleTranslation._meta.db_table
|
||||
@@ -70,4 +70,7 @@ class SchemaIndexesTests(TestCase):
|
||||
if storage != "InnoDB":
|
||||
self.skip("This test only applies to the InnoDB storage engine")
|
||||
index_sql = connection.schema_editor()._model_indexes_sql(ArticleTranslation)
|
||||
self.assertEqual(index_sql, [])
|
||||
self.assertEqual(index_sql, [
|
||||
'CREATE INDEX `indexes_articletranslation_99fb53c2` '
|
||||
'ON `indexes_articletranslation` (`article_no_constraint_id`)'
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user