#34996: Enhance update_or_create() method with upsert SQL.
-------------------------------------+-------------------------------------
Reporter: Jordan Bae | Owner: nobody
Type: New feature | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):
* status: new => closed
* type: Cleanup/optimization => New feature
* resolution: => wontfix
Comment:
Thanks for this ticket, however, this change would be backward
incompatible as `get_or_create()` is
[https://docs.djangoproject.com/en/stable/ref/models/querysets/#update-or-
create documented] to be a shortcut for the pattern:
{{{#!python
try:
<<get>>
<<save>>
except DoesNotExist:
<<update>>
}}}
With your proposition `save()` would not be called anymore (and folks have
a custom logic in their `save()` methods). Moreover support for "UPSERT"
varies in databases, and it's already possible to do this with passing a
single object to the `bulk_create()`.
--
Ticket URL: <https://code.djangoproject.com/ticket/34996#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107018c0f1b2606-610dc35c-7d33-4d1c-a73b-b3afd47b2754-000000%40eu-central-1.amazonses.com.