#36550: AssertionError raised when bulk creation model with primary key set via
pre_save (e.g. auto_now_add) on databases with
can_return_columns_from_insert
-------------------------------------+-------------------------------------
     Reporter:  Will-Ruddick         |                    Owner:  Jason
                                     |  Hall
         Type:  Bug                  |                   Status:  assigned
    Component:  Database layer       |                  Version:  dev
  (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 Jason Hall):

 Here is what I came up with this morning...

 This patch updates QuerySet._prepare_for_bulk_create() to correctly
 classify objects when using composite primary keys and auto_now_add
 fields.  Instead of relying only on _is_pk_set(), it checks that all PK
 fields are populated (non-None and not DatabaseDefault) before treating an
 object as "with PK".

 Also, I modifed the original regression test from previous comments.  This
 is now backend agnostic and it ensures that objects bulk-created with a
 composite PK and auto_now_add values still have their primary key set
 correctly both in memory and in the database.

 Looking forward to reading what you all think of this.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36550#comment:12>
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 view this discussion visit 
https://groups.google.com/d/msgid/django-updates/01070198b3b85889-b1914a07-e984-4284-86d6-bdd1541d602e-000000%40eu-central-1.amazonses.com.

Reply via email to