#34282: Optimize update_or_create when defaults is empty / False-y
-------------------------------------+-------------------------------------
     Reporter:  Timothy Schilling    |                    Owner:  Timothy
         Type:                       |  Schilling
  Cleanup/optimization               |                   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:  assigned => closed
 * resolution:   => wontfix


Comment:

 Thanks for this ticket. An empty set of `defaults` is always a subset of
 `concrete_field_names` so
 
[https://github.com/django/django/blob/0fd5d16c222583dd68128b70b17e461d4decda8c/django/db/models/query.py#L971-L972
 the "else" branch] is not reachable in this case. We could skip
 
[https://github.com/django/django/blob/0fd5d16c222583dd68128b70b17e461d4decda8c/django/db/models/query.py#L970
 save()] when `update_fields` is empty but this would be backward
 incompatible e.g. for users with database triggers. I'm not convinced it's
 worth changing, users who don't want to update any fields should use
 `get_or_create()` instead. Hope that makes sense.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34282#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/01070185dd99309b-2aba43f1-3194-483a-a00f-2b01150a05d4-000000%40eu-central-1.amazonses.com.

Reply via email to