#24997: Allow bulk_create with proxy inheritance
-------------------------------------+-------------------------------------
     Reporter:  wkschwartz           |                    Owner:  nobody
         Type:  New feature          |                   Status:  new
    Component:  Database layer       |                  Version:  1.8
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  proxy, inheritance,  |             Triage Stage:  Accepted
  bulk_create, queryset, insert      |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by wkschwartz):

 I'll try to work this up into a real patch, but what I found was that the
 following changes relative to the code at git tag 1.8.2 make the test
 cases described in this ticket pass.

 {{{#!python
 --- django/db/models/query.py   2015-06-17 17:29:38.000000000 -0400
 +++ django/db/models/query.py   2015-06-17 17:31:26.000000000 -0400
 @@ -370,13 +370,13 @@
          # this by using RETURNING clause for the insert query. We're
 punting
          # on these for now because they are relatively rare cases.
          assert batch_size is None or batch_size > 0
 -        if self.model._meta.parents and not self.model._meta.proxy:
 +        if self.model._meta.parents:
              raise ValueError("Can't bulk create an inherited model")
          if not objs:
              return objs
          self._for_write = True
          connection = connections[self.db]
 -        fields = self.model._meta.concrete_fields
 +        fields = self.model._meta.local_concrete_fields
          objs = list(objs)
          self._populate_pk_values(objs)
          with transaction.atomic(using=self.db, savepoint=False):
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24997#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/068.dd1b062aa5a27b9988586100d22e547e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to