Opened 4 years ago
Closed 4 years ago
#32703 closed Bug (invalid)
Deferred UniqueConstraints should not be validated in validate_unique()
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 (last modified by )
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 instances 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
.
Change History (4)
comment:1 by , 4 years ago
Cc: | added |
---|
comment:2 by , 4 years ago
Needs documentation: | set |
---|
comment:3 by , 4 years ago
Description: | modified (diff) |
---|
comment:4 by , 4 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
The save method used in my test is broken.
validate_unique()
is not called in the situation described above.