﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
28821	Allow QuerySet.bulk_create() on multi-table inheritance when possible	Joey Wilhelm	HAMA Barhamou	"According to [https://github.com/django/django/blob/a2626cb3fec2e67bb0ec4be2e992e1a836b7567e/django/db/models/query.py#L423 this comment] in `bulk_create`:

{{{#!python
        # When you bulk insert you don't get the primary keys back (if it's an
        # autoincrement, except if can_return_ids_from_bulk_insert=True), so
        # you can't insert into the child tables which references this.
}}}

This implies that, if we do retrieve primary keys from the parent model's bulk insert, then it is possible to bulk insert into the child tables automatically.

Now that Django does have the ability to automatically retrieve, and set, primary keys on a bulk create operation, it would be nice to allow this use case when possible (specifically, when the backend has `can_return_ids_from_bulk_insert=True`). Keying it off this feature would give PostgreSQL this ability immediately, and then let it work for Oracle as soon as retrieval of PKs is fully supported on that engine as well.

Also, regardless if Django does this automatically, I would like to be able to manually set the `_ptr` fields on the child records in order to affect a bulk_create without the need for automatic retrieval of IDs. However, even that is not possible, as the `bulk_create` method [https://github.com/django/django/blob/a2626cb3fec2e67bb0ec4be2e992e1a836b7567e/django/db/models/query.py#L448 fails on multi-table inheritance in all cases].
"	New feature	assigned	Database layer (models, ORM)	dev	Normal		multi-table, MTI, bulk-creation, optimization, queryset, sql	Abhishek Gautam jon.dufresne@… Shai Berger Adam Johnson Arthur Paolo Melchiorre	Accepted	1	0	0	0	0	0
