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@…||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 (22)
comment:1 Changed 15 months ago by akaariai
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
comment:3 Changed 14 months ago by aaugustin
- Triage Stage changed from Unreviewed to Design decision needed
comment:4 Changed 14 months ago by charettes
- Cc charette.s@… added
- Version changed from 1.4 to master
comment:9 Changed 12 months ago by aaugustin
- Triage Stage changed from Design decision needed to Accepted