1
0
mirror of https://github.com/django/django.git synced 2025-10-25 06:36:07 +00:00

[5.1.x] Fixed #35638 -- Updated validate_constraints to consider db_default.

Backport of 509763c799 from main.
This commit is contained in:
David Sanders
2024-08-05 08:22:29 +02:00
committed by Sarah Boyce
parent 78654a29b8
commit aed4ffe189
10 changed files with 130 additions and 13 deletions

View File

@@ -1238,3 +1238,12 @@ class ExclusionConstraintTests(PostgreSQLTestCase):
constraint_name,
self.get_constraints(ModelWithExclusionConstraint._meta.db_table),
)
def test_database_default(self):
constraint = ExclusionConstraint(
name="ints_equal", expressions=[("ints", RangeOperators.EQUAL)]
)
RangesModel.objects.create()
msg = "Constraint “ints_equal” is violated."
with self.assertRaisesMessage(ValidationError, msg):
constraint.validate(RangesModel, RangesModel())