Opened 4 years ago

Closed 3 years ago

Last modified 2 years ago

#31685 closed New feature (fixed)

Support updating conflicts with QuerySet.bulk_create().

Reported by: Vitor Pereira Owned by: Chih Sean Hsu
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords: bulk insert update upsert
Cc: Tom Forbes, Chih Sean Hsu, Adam Johnson Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

It would be useful having a parameter in bulk_create(), like bulk_create(objs, upsert=True) or bulk_create(objs, update_conflicts=True), that lets you update existing rows when there's a conflict, much like what you can already do for a single entity with update_or_create().

Change History (21)

comment:1 by Mariusz Felisiak, 4 years ago

Cc: Tom Forbes added
Summary: Add `update_or_create()` in bulkSupport updating conflicts with QuerySet.bulk_create().
Triage Stage: UnreviewedAccepted

Agreed, it would be great to support updating conflicts with bulk_create():

comment:2 by Chih Sean Hsu, 4 years ago

Cc: Chih Sean Hsu added
Owner: changed from nobody to Chih Sean Hsu
Status: newassigned

comment:3 by Chih Sean Hsu, 4 years ago

I have opened PR https://github.com/django/django/pull/13065. It is still on going.

comment:4 by Chih Sean Hsu, 4 years ago

Has patch: set
Needs documentation: set
Needs tests: set

comment:5 by Chih Sean Hsu, 4 years ago

Needs documentation: unset
Needs tests: unset

comment:6 by Chih Sean Hsu, 4 years ago

It's done and waiting for review.

comment:7 by Alexandr Tatarinov, 4 years ago

Added a comment to pull request about potential room for improvement.

comment:8 by Adam Johnson, 4 years ago

Cc: Adam Johnson added

comment:9 by Mariusz Felisiak, 3 years ago

Patch needs improvement: set

comment:10 by Chih Sean Hsu, 3 years ago

Patch needs improvement: unset

comment:11 by Mariusz Felisiak, 3 years ago

Needs documentation: set
Patch needs improvement: set

comment:12 by Chih Sean Hsu, 3 years ago

Needs documentation: unset
Patch needs improvement: unset

comment:13 by Mariusz Felisiak, 3 years ago

Needs tests: set
Patch needs improvement: set

comment:14 by Chih Sean Hsu, 3 years ago

Patch needs improvement: unset

comment:15 by Chih Sean Hsu, 3 years ago

Needs tests: unset

comment:16 by Mariusz Felisiak, 3 years ago

Patch needs improvement: set

comment:17 by Chih Sean Hsu, 3 years ago

Patch needs improvement: unset

comment:18 by Mariusz Felisiak, 3 years ago

Triage Stage: AcceptedReady for checkin

comment:19 by Mariusz Felisiak <felisiak.mariusz@…>, 3 years ago

Resolution: fixed
Status: assignedclosed

In 0f694649:

Fixed #31685 -- Added support for updating conflicts to QuerySet.bulk_create().

Thanks Florian Apolloner, Chris Jerdonek, Hannes Ljungberg, Nick Pope,
and Mariusz Felisiak for reviews.

comment:20 by Mariusz Felisiak <felisiak.mariusz@…>, 2 years ago

In c627226d:

Fixed #33799, Refs #31685 -- Added parameters for updating conflicts to QuerySeta.abulk_create().

comment:21 by Mariusz Felisiak <felisiak.mariusz@…>, 2 years ago

In 531c96de:

[4.1.x] Fixed #33799, Refs #31685 -- Added parameters for updating conflicts to QuerySeta.abulk_create().

Backport of c627226d05dd52aef59447dcfb29cec2c2b11b8a from main

Note: See TracTickets for help on using tickets.
Back to Top