#29260: Django makes an extra UPDATE query when custom PK is evaluating before
save.
-------------------------------------+-------------------------------------
     Reporter:  user0007             |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  2.0
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Tim Graham):

 I'm not sure if the issue can or should be fixed. For the model you gave,
 an instance will have an `id` from `default=uuid.uuid4`, so
 [https://docs.djangoproject.com/en/stable/ref/models/instances/#how-
 django-knows-to-update-vs-insert as documented] an `UPDATE` is tried
 
([https://github.com/django/django/blob/4554f9a783665d64b59c35b53ae71178e56ac783/django/db/models/base.py#L804-L805
 code]). A fix might try to detect if the primary key came from a `default`
 and if so, skip the update.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29260#comment:2>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.fb8ccdaf9d20dc9a4e5bf0cbdc5b6ce2%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to