diff options
| author | David Wobrock <david.wobrock@gmail.com> | 2022-07-11 08:23:50 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-07-11 08:30:19 +0200 |
| commit | f8f16b3cd85599b464cbc5c7e884387940c24e6f (patch) | |
| tree | 3363474cfa67fbf0b03f8f8f6e076e4b664d0e26 | |
| parent | 77330a089cdf33533a387225c01736ab353b20fe (diff) | |
Refs #27236 -- Removed usage of Meta.index_together from indexes/introspection test models.
| -rw-r--r-- | tests/indexes/models.py | 4 | ||||
| -rw-r--r-- | tests/indexes/tests.py | 10 | ||||
| -rw-r--r-- | 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"]), ] |
