Hi, I worked on supporting bulk_insert for multi table inheritance here [1] I would like to get some feedback.
bulk_create can be used in one of 2 ways 1) If you already have parent records in the database and want to bulk_insert into the child table only. 2) There isn't any parent records, and need to create them as well. In the first case, all database backends can support it. It simply requires the user to set the `parent_ptr` attributes for all child instances, and then do bulk_create. In the second case it gets tricky and it cannot be supported for all databases for any model as it requires a way to get all the ids from the inserted parent records. Postgres is the most flexible in that case and supports bulk_insert for any table and any type of field because it supports the RETURNING clause so we can always retrieve the ids for the inserted rows. For sqlite we can only support bulk_create if the model does not have a parent with an AutoField. for MySQL I think we can rely on `LAST_INSERT_ID()` which will return the first ID out of the rows count inserted, so we can than generate a list of IDs of `range(last_insert_id, last_insert_id + count_rows)`. Can anyone confirm if we can rely on MySQL last_insert_id to be consistent and and without gaps for all records inserted at once? Thanks. [1] https://github.com/django/django/compare/master...ar45:allow_bulk_insert_multi_inheritance -- Aron Podrigal - '1000001', '1110010', '1101111', '1101110' '1010000', '1101111', '1100100', '1110010', '1101001', '1100111', '1100001', '1101100' P: '2b', '31', '33', '34', '37', '34', '35', '38', '36', '30', '39', '39' -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CANJp-yh7SXmC1a3T3RZjdDApdAqo6Op06DsQCqOQ0LhbmVhY5g%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
