Skip to content

Commit

Permalink
Fixed #28147 -- Added test for saving nullable parent then child with…
Browse files Browse the repository at this point in the history
… to_field
  • Loading branch information
xmeowmeowx committed May 20, 2019
1 parent e86cc14 commit 5f9ad40
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/many_to_one/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,16 @@ def test_fk_assignment_and_related_object_cache(self):
self.assertIsNot(c.parent, p)
self.assertEqual(c.parent, p)

def test_save_nullable_parent_then_child_to_field(self):
parent_id = "jeff"
parent = Parent(name=parent_id)
child = ToFieldChild(parent=parent)
parent.save()
child.save()
child.refresh_from_db()
self.assertEqual(child.parent, parent)
self.assertEqual(child.parent_id, parent_id)

def test_fk_to_bigautofield(self):
ch = City.objects.create(name='Chicago')
District.objects.create(city=ch, name='Far South')
Expand Down

0 comments on commit 5f9ad40

Please sign in to comment.