diff options
author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-08-09 06:08:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-09 06:08:48 +0200 |
commit | 63884829acd207404f2a5c3cc1d6b4cd0a822b70 (patch) | |
tree | 36bbc8a3fc155cd2f103589d9d260e0ba214788d /tests/constraints | |
parent | c614e811f80ae5ce4e8f1461f54f0600707cf0e6 (diff) | |
download | django-63884829acd207404f2a5c3cc1d6b4cd0a822b70.tar.gz |
Fixed #33902 -- Fixed Meta.constraints validation crash with F() expressions.
Thanks Adam Zahradník for the report.
Bug in 667105877e6723c6985399803a364848891513cc.
Diffstat (limited to 'tests/constraints')
-rw-r--r-- | tests/constraints/tests.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/constraints/tests.py b/tests/constraints/tests.py index 4032b418b4..d4054dfd77 100644 --- a/tests/constraints/tests.py +++ b/tests/constraints/tests.py @@ -685,6 +685,20 @@ class UniqueConstraintTests(TestCase): exclude={"color"}, ) + def test_validate_expression_str(self): + constraint = models.UniqueConstraint("name", name="name_uniq") + msg = "Constraint “name_uniq” is violated." + with self.assertRaisesMessage(ValidationError, msg): + constraint.validate( + UniqueConstraintProduct, + UniqueConstraintProduct(name=self.p1.name), + ) + constraint.validate( + UniqueConstraintProduct, + UniqueConstraintProduct(name=self.p1.name), + exclude={"name"}, + ) + def test_name(self): constraints = get_constraints(UniqueConstraintProduct._meta.db_table) expected_name = "name_color_uniq" |