#30382: force_insert flag is not passed when saving parents on inherited models.
-------------------------------------+-------------------------------------
     Reporter:  Phill Tornroth       |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Phill Tornroth):

 I started working on this. As is normal, it's note quite as easy as I
 hoped. The manager .create() methods assume force_insert and there's some
 previous behavior in tests (and so presumably in the wild) where code
 might do:

 {{{
 parent = ParentModel.objects.create()
 child = ChildModel.objects.create(parent=parent)
 }}}

 The create method will pass force_insert, so the second line fails because
 it attempts to insert the parent again. A prior attempt from @akaariai
 suggested breaking this behavior (which I'm game for, if the team
 suggests). I can't think of a reasonable alternative that doesn't involve
 some other backwards-incompatible change (like making force_insert an
 explicit argument to create).

 Here's the unmerged commit from @akaraaia:
 
https://github.com/akaariai/django/commit/57384c7936fbd8d760a36c47a41ecef18e451308
 From the (effectively duplicate) ticket:
 https://code.djangoproject.com/ticket/18305

-- 
Ticket URL: <https://code.djangoproject.com/ticket/30382#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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/072.e2c307a67fc011ef5d9816dafabf707b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to