diff --git a/tests/constraints/models.py b/tests/constraints/models.py
index 1460673a18..9a88ff83d1 100644
a
|
b
|
from django.db import models
|
4 | 4 | class Product(models.Model): |
5 | 5 | price = models.IntegerField(null=True) |
6 | 6 | discounted_price = models.IntegerField(null=True) |
| 7 | unit = models.CharField(max_length=15, null=True) |
7 | 8 | |
8 | 9 | class Meta: |
9 | 10 | required_db_features = { |
… |
… |
class Product(models.Model):
|
31 | 32 | ), |
32 | 33 | name='%(app_label)s_price_neq_500_wrap', |
33 | 34 | ), |
| 35 | models.CheckConstraint( |
| 36 | check=models.Q(unit__isnull=True) | models.Q(unit__in=['μg/mL', 'ng/mL']), |
| 37 | name='unicode_unit_list', |
| 38 | ), |
34 | 39 | ] |
35 | 40 | |
36 | 41 | |
diff --git a/tests/constraints/tests.py b/tests/constraints/tests.py
index d9e91bdf49..2796a0f30b 100644
a
|
b
|
class CheckConstraintTests(TestCase):
|
88 | 88 | with self.assertRaises(IntegrityError): |
89 | 89 | Product.objects.create(price=10, discounted_price=20) |
90 | 90 | |
| 91 | @skipUnlessDBFeature('supports_table_check_constraints') |
| 92 | def test_database_constraint_unicode(self): |
| 93 | Product.objects.create(price=10, discounted_price=5, unit='μg/mL') |
| 94 | with self.assertRaises(IntegrityError): |
| 95 | Product.objects.create(price=10, discounted_price=7, unit='l') |
| 96 | |
91 | 97 | @skipUnlessDBFeature('supports_table_check_constraints') |
92 | 98 | def test_database_constraint_expression(self): |
93 | 99 | Product.objects.create(price=999, discounted_price=5) |