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:
@@ -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",
|
||||
),
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user