summaryrefslogtreecommitdiff
path: root/tests/schema
diff options
context:
space:
mode:
authorSergey Fursov <geyser85@gmail.com>2021-12-29 00:18:17 +0300
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-09-13 10:38:57 +0200
commitb731e8841558ee4caaba766c83f34ea9c7004f8b (patch)
treefeb5596cfa8c5397ad3172f19c2985ecb4c41d19 /tests/schema
parent1b08e9bf7d88dbad9324f462e5fc7ec582aef3cc (diff)
downloaddjango-b731e8841558ee4caaba766c83f34ea9c7004f8b.tar.gz
Fixed #31335 -- Fixed removing composed composed Meta constraints/indexes on foreign keys on MySQL.
Diffstat (limited to 'tests/schema')
-rw-r--r--tests/schema/tests.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/schema/tests.py b/tests/schema/tests.py
index 941b28900e..aaf6dff2ff 100644
--- a/tests/schema/tests.py
+++ b/tests/schema/tests.py
@@ -2735,6 +2735,24 @@ class SchemaTests(TransactionTestCase):
editor.remove_index(Book, index)
self.assertNotIn(index.name, self.get_constraints(table))
+ def test_composed_index_with_fk(self):
+ index = Index(fields=["author", "title"], name="book_author_title_idx")
+ self._test_composed_index_with_fk(index)
+
+ def test_composed_desc_index_with_fk(self):
+ index = Index(fields=["-author", "title"], name="book_author_title_idx")
+ self._test_composed_index_with_fk(index)
+
+ @skipUnlessDBFeature("supports_expression_indexes")
+ def test_composed_func_index_with_fk(self):
+ index = Index(F("author"), F("title"), name="book_author_title_idx")
+ self._test_composed_index_with_fk(index)
+
+ @skipUnlessDBFeature("supports_expression_indexes")
+ def test_composed_desc_func_index_with_fk(self):
+ index = Index(F("author").desc(), F("title"), name="book_author_title_idx")
+ self._test_composed_index_with_fk(index)
+
@skipUnlessDBFeature("supports_expression_indexes")
def test_composed_func_transform_index_with_fk(self):
index = Index(F("title__lower"), name="book_title_lower_idx")
@@ -2756,6 +2774,13 @@ class SchemaTests(TransactionTestCase):
editor.remove_constraint(Book, constraint)
self.assertNotIn(constraint.name, self.get_constraints(table))
+ def test_composed_constraint_with_fk(self):
+ constraint = UniqueConstraint(
+ fields=["author", "title"],
+ name="book_author_title_uniq",
+ )
+ self._test_composed_constraint_with_fk(constraint)
+
@skipUnlessDBFeature(
"supports_column_check_constraints", "can_introspect_check_constraints"
)