#33770: Add bulk_update() support for unique fields instead of only primary key
-------------------------------------+-------------------------------------
               Reporter:  Ebram      |          Owner:  nobody
  Shehata                            |
                   Type:  New        |         Status:  new
  feature                            |
              Component:  Database   |        Version:  4.0
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:  models, orm
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 Currently, `bulk_update()` function from `django.db.models.query` only
 performs the update using the primary key field..

 I think we can generalize it more to use a unique field..
 Example: `MyModel.objects.bulk_update(objs, fields=["name"],
 unique_field="national_id")`
 This will use `MyModel.national_id` to identify objects since
 `national_id` is unique.
 I wrote the code for it and I thought to contribute it to Django..

 I also have a question about that function, we can't use it to update
 primary keys.. I'm wondering why ? I want to also add that support to it.

 Note: I'm not really sure what to do to reserve the implementation for me.
 I want to be the one to implement it, actually, I already wrote the code.

 Here's a PR I created: https://github.com/django/django/pull/15764

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33770>
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/0107018136afa06b-dbbfe855-6dc2-4d11-869e-83fbc4f5317e-000000%40eu-central-1.amazonses.com.

Reply via email to