bulk_create() can set the primary key
|Reported by:||Tuttle||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||master|
|Cc:||charette.s@…, gwahl@…, w2lkm2n@…, mszamot@…, AkosLadanyi, shai, acrefoot@…, benth, dev@…||Triage Stage:||Accepted|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||yes||Patch needs improvement:||yes|
(Sorry if I missed a pre-existing ticket for this.)
There is an IMO big caveat of bulk_create(): It does not set primary key of objects it creates.
In my current project, using bulk_create would improve performance, but as I often need an id of the newly created objects, I have to save them one by one.
I think it would be perfect if bulk_create starts to set the primary keys of the objects in the given sequence. At least postgresql supports it ("RETURNING id" clause gives us a set of id's).
Change History (25)
comment:1 Changed 3 years ago by akaariai
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
comment:3 Changed 3 years ago by aaugustin
- Triage Stage changed from Unreviewed to Design decision needed
comment:9 Changed 2 years ago by aaugustin
- Triage Stage changed from Design decision needed to Accepted