summaryrefslogtreecommitdiff
path: root/tests/constraints/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/constraints/models.py')
-rw-r--r--tests/constraints/models.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/tests/constraints/models.py b/tests/constraints/models.py
index fb6ef620f0..d207de6e73 100644
--- a/tests/constraints/models.py
+++ b/tests/constraints/models.py
@@ -2,12 +2,13 @@ from django.db import models
class Product(models.Model):
- name = models.CharField(max_length=255)
- color = models.CharField(max_length=32, null=True)
price = models.IntegerField(null=True)
discounted_price = models.IntegerField(null=True)
class Meta:
+ required_db_features = {
+ 'supports_table_check_constraints',
+ }
constraints = [
models.CheckConstraint(
check=models.Q(price__gt=models.F('discounted_price')),
@@ -17,6 +18,15 @@ class Product(models.Model):
check=models.Q(price__gt=0),
name='%(app_label)s_%(class)s_price_gt_0',
),
+ ]
+
+
+class UniqueConstraintProduct(models.Model):
+ name = models.CharField(max_length=255)
+ color = models.CharField(max_length=32, null=True)
+
+ class Meta:
+ constraints = [
models.UniqueConstraint(fields=['name', 'color'], name='name_color_uniq'),
models.UniqueConstraint(
fields=['name'],
@@ -31,6 +41,9 @@ class AbstractModel(models.Model):
class Meta:
abstract = True
+ required_db_features = {
+ 'supports_table_check_constraints',
+ }
constraints = [
models.CheckConstraint(
check=models.Q(age__gte=18),