﻿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
33322	Saving parent object after setting on child leads to unexpected data loss in bulk_update().	GwynBleidD	Hannes Ljungberg	"Consider following example:

{{{
class Child(models.Model):
    pass


class Parent(models.Model):
    child = models.ForeignKey(Child, on_delete=models.CASCADE, null=True)
}}}

{{{
parent = Parent.objects.create(child=None)

parent.child = Child()
parent.child.save()

Parent.objects.bulk_update([parent], fields=[""child""])
}}}

Expected behavior:
parent model instance was updated with the ID to the child in the database.

Actual behavior:
Parent model is still referencing Null.

There should probably be some check for ForeignKeys in the bulk_update logic, and if one is updated, the ID of the child model should be re-copied to the child_id field that is actually being written to the database."	Bug	closed	Database layer (models, ORM)	3.2	Normal	fixed		Hannes Ljungberg Egor R	Ready for checkin	1	0	0	0	0	0
