This would only be possible when value has a default, and we would need to
resolve the F() object to the default. It may be that we need a different
object which resolves to an expression when used in an update but resolves
differently when used in a create.
--
Ticket URL: <https://code.djangoproject.com/ticket/25195>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/25195#comment:1>
Comment (by ghazpar):
How about the following?
{{{
Foo.objects.update_or_create(name='bar', defaults={'value':
Coalesce('value', 0) + 1})
}}}
where one could specify an explicit default?
--
Ticket URL: <https://code.djangoproject.com/ticket/25195#comment:2>
Comment (by Simon Charette):
Replying to [comment:2 Marc Parizeau]:
> How about the following?
>
> {{{
> Foo.objects.update_or_create(name='bar', defaults={'value':
Coalesce('value', 0) + 1})
> }}}
>
> where one could specify an explicit default?
We'd need to special case `Coalesce` in `update_or_create` for this to
work as references to columns are not allowed in `INSERT`s.
--
Ticket URL: <https://code.djangoproject.com/ticket/25195#comment:3>