Opened 4 years ago

Last modified 4 years ago

#32703 closed Bug

Deferred UniqueConstraints should not be validated in validate_unique() — at Version 3

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 Manuel Baclet)

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 (3)

comment:1 by Manuel Baclet, 4 years ago

Cc: Manuel Baclet added

comment:2 by Manuel Baclet, 4 years ago

Needs documentation: set

comment:3 by Manuel Baclet, 4 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top