From f8f16b3cd85599b464cbc5c7e884387940c24e6f Mon Sep 17 00:00:00 2001 From: David Wobrock Date: Mon, 11 Jul 2022 08:23:50 +0200 Subject: [PATCH] Refs #27236 -- Removed usage of Meta.index_together from indexes/introspection test models. --- tests/indexes/models.py | 4 +--- tests/indexes/tests.py | 10 +++------- tests/introspection/models.py | 6 +++--- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/tests/indexes/models.py b/tests/indexes/models.py index f7fcb6175c..6f6f82bbcb 100644 --- a/tests/indexes/models.py +++ b/tests/indexes/models.py @@ -38,9 +38,7 @@ class Article(models.Model): ) class Meta: - index_together = [ - ["headline", "pub_date"], - ] + indexes = [models.Index(fields=["headline", "pub_date"])] class IndexedArticle(models.Model): diff --git a/tests/indexes/tests.py b/tests/indexes/tests.py index 11f72850f3..fb7796ddf8 100644 --- a/tests/indexes/tests.py +++ b/tests/indexes/tests.py @@ -68,17 +68,13 @@ class SchemaIndexesTests(TestCase): ) self.assertEqual(index_name, expected[connection.vendor]) - def test_index_together(self): + def test_quoted_index_name(self): editor = connection.schema_editor() index_sql = [str(statement) for statement in editor._model_indexes_sql(Article)] self.assertEqual(len(index_sql), 1) - # Ensure the index name is properly quoted + # Ensure the index name is properly quoted. self.assertIn( - connection.ops.quote_name( - editor._create_index_name( - Article._meta.db_table, ["headline", "pub_date"], suffix="_idx" - ) - ), + connection.ops.quote_name(Article._meta.indexes[0].name), index_sql[0], ) diff --git a/tests/introspection/models.py b/tests/introspection/models.py index 6381e3481c..31c1b0de80 100644 --- a/tests/introspection/models.py +++ b/tests/introspection/models.py @@ -41,9 +41,9 @@ class Article(models.Model): class Meta: ordering = ("headline",) - index_together = [ - ["headline", "pub_date"], - ["headline", "response_to", "pub_date", "reporter"], + indexes = [ + models.Index(fields=["headline", "pub_date"]), + models.Index(fields=["headline", "response_to", "pub_date", "reporter"]), ]