#36566: Allow customization of returning_fields in bulk_create
------------------------------+-----------------------------------------
     Reporter:  Take Weiland  |                     Type:  Uncategorized
       Status:  new           |                Component:  Uncategorized
      Version:  5.2           |                 Severity:  Normal
     Keywords:                |             Triage Stage:  Unreviewed
    Has patch:  0             |      Needs documentation:  0
  Needs tests:  0             |  Patch needs improvement:  0
Easy pickings:  0             |                    UI/UX:  0
------------------------------+-----------------------------------------
 On databases that support `INSERT ... RETURNING` (all but MySQL),
 `bulk_create` will use it to retrieve the values of generated columns of
 the inserted rows. "generated columns" currently being `AutoField` and
 `GeneratedField`. These are marked using `db_returning = True`.

 This is sufficient for standard uses of `bulk_create`. However
 `bulk_create` supports a parameter named `update_conflicts`. In case
 `update_conflicts` Django should use `INSERT ... RETURNING` for at least
 the primary key, regardless of whether it is an `AutoField` or not. This
 way the objects returned by `bulk_create` will have the correct primary
 key set, regardless of whether they were inserted or updated.

 I would also propose adding another parameter to `bulk_create` (e.g.
 `returning_fields`) to let users specify additional fields Django should
 fetch using `INSERT ... RETURNING`. This way users can specify additional
 fields that they need to be up to date in the returned objects when using
 `update_conflicts`.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36566>
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 visit 
https://groups.google.com/d/msgid/django-updates/01070198cd0fe95f-f43c6dc7-5f50-4814-aec0-4331e3ab2b6c-000000%40eu-central-1.amazonses.com.

Reply via email to