#31071: Change in behaviour when saving a model instance with an explcit pk 
value
if the pk field has a default
-------------------------------------+-------------------------------------
     Reporter:  Reupen Shah          |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  3.0
  (models, ORM)                      |
     Severity:  Release blocker      |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

 * severity:  Normal => Release blocker
 * stage:  Unreviewed => Accepted


Comment:

 It looks like [https://github.com/django/django/pull/11680/files#diff-
 507b415116b409afa4f723e41a759a9eR846-R853 the logic] in `_save_table`
 should not force an insert if an explicit `pk` value is provided.

 The logic should likely take `pk_set` into account

 {{{#!python
 if (
     not pk_set
     and self._state.adding
     and self._meta.pk.default
     and self._meta.pk.default is not NOT_PROVIDED
 ):
     force_insert = True
 }}}

 I'm surprised this was not caught by the suite if this breaks fixtures
 loading.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31071#comment:3>
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/064.aa969077f29b4a67ab42c59b50e42ba7%40djangoproject.com.

Reply via email to