mirror of
https://github.com/django/django.git
synced 2025-06-05 11:39:13 +00:00
Refs #35038 -- Added test for drop and recreation of a constraint.
This commit is contained in:
parent
1722f2db58
commit
b92511b474
@ -2981,6 +2981,43 @@ class AutodetectorTests(BaseAutodetectorTests):
|
|||||||
changes, "testapp", 0, 0, model_name="author", name="name_contains_bob"
|
changes, "testapp", 0, 0, model_name="author", name="name_contains_bob"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_constraint_dropped_and_recreated(self):
|
||||||
|
altered_constraint = models.CheckConstraint(
|
||||||
|
condition=models.Q(name__contains="bob"),
|
||||||
|
name="name_contains_bob",
|
||||||
|
)
|
||||||
|
author_name_check_constraint_lowercased = copy.deepcopy(
|
||||||
|
self.author_name_check_constraint
|
||||||
|
)
|
||||||
|
author_name_check_constraint_lowercased.options = {
|
||||||
|
"constraints": [altered_constraint]
|
||||||
|
}
|
||||||
|
changes = self.get_changes(
|
||||||
|
[self.author_name_check_constraint],
|
||||||
|
[author_name_check_constraint_lowercased],
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertNumberMigrations(changes, "testapp", 1)
|
||||||
|
self.assertOperationTypes(
|
||||||
|
changes, "testapp", 0, ["RemoveConstraint", "AddConstraint"]
|
||||||
|
)
|
||||||
|
self.assertOperationAttributes(
|
||||||
|
changes,
|
||||||
|
"testapp",
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
model_name="author",
|
||||||
|
name="name_contains_bob",
|
||||||
|
)
|
||||||
|
self.assertOperationAttributes(
|
||||||
|
changes,
|
||||||
|
"testapp",
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
model_name="author",
|
||||||
|
constraint=altered_constraint,
|
||||||
|
)
|
||||||
|
|
||||||
def test_add_unique_together(self):
|
def test_add_unique_together(self):
|
||||||
"""Tests unique_together detection."""
|
"""Tests unique_together detection."""
|
||||||
changes = self.get_changes(
|
changes = self.get_changes(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user