Opened 7 years ago
Last modified 6 years ago
#28668 closed New feature
Add support for ON CONFLICT to bulk_create — at Version 1
Reported by: | Tom Forbes | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Дилян Палаузов | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
When using bulk_create it would be nice to support ON CONFLICT DO NOTHING
, which allows existing rows to be included in the bulk_create
call, e.g:
Comment.objects.create(name='test', text='test') Comment.objects.bulk_create(Comment(name='test', text='test'), on_conflict=IGNORE) # Does not throw an exception
All the databases we support have syntax for this, as well as updating/replacing fields.
This is a spin-off of https://code.djangoproject.com/ticket/28641, just including the ON CONFLICT idea which is backwards-compatible and would be easier to implement than the others.
Note:
See TracTickets
for help on using tickets.