Opened 5 years ago
Last modified 5 years ago
#32703 closed Bug
Deferred UniqueConstraints should not be validated in validate_unique() — at Initial Version
| Reported by: | Manuel Baclet | Owned by: | nobody |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | 3.1 |
| Severity: | Normal | Keywords: | UniqueConstraint deferrable |
| Cc: | Manuel Baclet | Triage Stage: | Unreviewed |
| Has patch: | no | Needs documentation: | yes |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | yes | UI/UX: | no |
Description
When using a deferred UniqueConstraint, we are expecting validation not to occur before transaction commit.
Considering a model with a field unique_valued_field with a deferred UniqueConstraint and two models m1 and m2, we should be able to do:
with transaction.atomic(): saved_value = m1.unique_valued_field m1.unique_valued_field = m2.unique_valued_field m2.unique_valued_field = saved_value m1.save() m2.save()
Currently, this raises a ValidationError.
Note:
See TracTickets
for help on using tickets.