﻿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
32133	bulk_create of parent after setting on child leads to unexpected data loss	Hannes Ljungberg	Hannes Ljungberg	"I think this is a missed case of https://code.djangoproject.com/ticket/28147. The behaviour is exactly the same but affects `bulk_update`.

Failing testcase:
{{{
parent = NoFields()
child = NullableFields(auto_field=parent)
NoFields.objects.bulk_create([parent])
NullableFields.objects.bulk_create([child])
child.refresh_from_db()
self.assertEqual(child.auto_field, parent)
}}}

This behaviour was also described in https://code.djangoproject.com/ticket/29497 but might’ve been missed when closed as a duplicate.

My proposal is to extract the code in `Model.save()` which ensures that all fields are in sync before save to it’s own method which can then be used by `bulk_update`.
"	Bug	closed	Database layer (models, ORM)	3.1	Normal	duplicate			Unreviewed	1	0	0	0	0	0
