1
0
mirror of https://github.com/django/django.git synced 2025-10-28 08:06:09 +00:00

Refs #36580 -- Added coverage for excluding ForeignObject from constraint validation.

This commit is contained in:
SaJH
2025-09-15 19:55:20 -04:00
committed by Jacob Walls
parent 82b3b84a78
commit 308f674e6d
3 changed files with 29 additions and 1 deletions

View File

@@ -39,3 +39,22 @@ class Contact(models.Model):
to_fields=["customer_id", "company"],
from_fields=["customer_code", "company_code"],
)
class CustomerTab(models.Model):
customer_id = models.IntegerField()
customer = models.ForeignObject(
Customer,
from_fields=["customer_id"],
to_fields=["id"],
on_delete=models.CASCADE,
)
class Meta:
required_db_features = {"supports_table_check_constraints"}
constraints = [
models.CheckConstraint(
condition=models.Q(customer__lt=1000),
name="customer_id_limit",
),
]