Opened 7 years ago
Last modified 6 years ago
#28668 closed New feature
Add ON CONFLICT support to QuerySet.bulk_create() — at Version 2
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 #28641, just including the ON CONFLICT idea which is backwards-compatible and would be easier to implement than the others.
Change History (2)
comment:1 by , 7 years ago
Description: | modified (diff) |
---|
comment:2 by , 7 years ago
Description: | modified (diff) |
---|---|
Summary: | Add support for ON CONFLICT to bulk_create → Add ON CONFLICT support to QuerySet.bulk_create() |
Triage Stage: | Unreviewed → Accepted |
Note:
See TracTickets
for help on using tickets.