diff options
| author | Hannes Ljungberg <hannes.ljungberg@gmail.com> | 2021-12-04 21:03:38 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-12-06 07:59:11 +0100 |
| commit | 1eaf38fa87384fe26d1abf6e389d6df1600d4d8c (patch) | |
| tree | ca6d2b877127ca1ea1f76d8e36dc51d708996474 /tests/validation/models.py | |
| parent | d3a64bea51676fcf8a0ae593cf7b103939e12c87 (diff) | |
Fixed #33335 -- Made model validation ignore functional unique constraints.
Regression in 3aa545281e0c0f9fac93753e3769df9e0334dbaa.
Thanks Hervé Le Roy for the report.
Diffstat (limited to 'tests/validation/models.py')
| -rw-r--r-- | tests/validation/models.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/validation/models.py b/tests/validation/models.py index 3a5a9cd354..b2d705aed2 100644 --- a/tests/validation/models.py +++ b/tests/validation/models.py @@ -2,6 +2,7 @@ from datetime import datetime from django.core.exceptions import ValidationError from django.db import models +from django.db.models.functions import Lower def validate_answer_to_universe(value): @@ -125,3 +126,13 @@ class GenericIPAddressTestModel(models.Model): class GenericIPAddrUnpackUniqueTest(models.Model): generic_v4unpack_ip = models.GenericIPAddressField(null=True, blank=True, unique=True, unpack_ipv4=True) + + +class UniqueFuncConstraintModel(models.Model): + field = models.CharField(max_length=255) + + class Meta: + required_db_features = {'supports_expression_indexes'} + constraints = [ + models.UniqueConstraint(Lower('field'), name='func_lower_field_uq'), + ] |
