#28668: Add ON CONFLICT support to QuerySet.bulk_create() -------------------------------------+------------------------------------- Reporter: Tom Forbes | Owner: Tom | Forbes Type: New feature | Status: assigned Component: Database layer | Version: master (models, ORM) | Severity: Normal | Resolution: Keywords: | Triage Stage: Accepted Has patch: 1 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+------------------------------------- Changes (by Дилян Палаузов):
* Attachment "on_conflict_ignore.patch" added. The on_conflict_ignore.patch adds on_conflict='ignore' to QuerySet.bulk_create and empowers bulk_create optionally to send post_save signals, when the ID of the inserted object is known to bulk_create. For postgresql bulk_create offers in addition to retrieve the IDs of the newly inserted objects, when using on_conflict='ignore' and, with a second query, to find the PKs pf the supplied objs that were already in the databse. When supported by the backend (so not Oracle), on_conflict='ignore' is added to bulk_create() in django.db.models.fields.create_forward_many_to_many_manager.ManyRelatedManager._add_items, making ManyRelatedManager.add() thread-safe, possibly resolving #19544. I have the feeling reset_sequence = True doesn't work as expected, as the IDs are random. This patch integrated the changes of om Forbes and previous changes of me. -- Ticket URL: <https://code.djangoproject.com/ticket/28668> 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/061.eef8d2ba2e5ed1b30d31df9f05cd18ea%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.