--
Ticket URL: <https://code.djangoproject.com/ticket/32703>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* cc: Manuel Baclet (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/32703#comment:1>
* needs_docs: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/32703#comment:2>
Old 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:
> {{{#!python
> 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`.
New 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 instances `m1` and `m2`, we should be able to do:
{{{#!python
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`.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/32703#comment:3>
* status: new => closed
* resolution: => invalid
Comment:
The save method used in my test is broken. `validate_unique()` is not
called in the situation described above.
--
Ticket URL: <https://code.djangoproject.com/ticket/32703#comment:4>