Opened 2 years ago

Last modified 2 years ago

#25195 new New feature

update_or_create doesn't understand F() operations

Reported by: Marc Tamlyn Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

This may not be possible to resolve, but it would be really nice if you could do something like

Foo.objects.update_or_create(name='bar', defaults={'value': F('value') + 1})

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.

Change History (1)

comment:1 Changed 2 years ago by Tim Graham

Triage Stage: UnreviewedAccepted
Note: See TracTickets for help on using tickets.
Back to Top