mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #33191 -- Avoided clearing cached reference when saving child after parent.
Thanks Barry Johnson for the report.
This commit is contained in:
committed by
Mariusz Felisiak
parent
f1e0fc645b
commit
1058fc7023
@@ -654,6 +654,16 @@ class ManyToOneTests(TestCase):
|
||||
self.assertIsNot(c.parent, p)
|
||||
self.assertEqual(c.parent, p)
|
||||
|
||||
def test_save_parent_after_assign(self):
|
||||
category = Category(name="cats")
|
||||
record = Record(category=category)
|
||||
category.save()
|
||||
record.save()
|
||||
category.name = "dogs"
|
||||
with self.assertNumQueries(0):
|
||||
self.assertEqual(category.id, record.category_id)
|
||||
self.assertEqual(category.name, record.category.name)
|
||||
|
||||
def test_save_nullable_fk_after_parent(self):
|
||||
parent = Parent()
|
||||
child = ChildNullableParent(parent=parent)
|
||||
|
||||
Reference in New Issue
Block a user