summaryrefslogtreecommitdiff
path: root/tests/model_inheritance/tests.py
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2017-11-23 02:14:32 -0500
committerSimon Charette <charette.s@gmail.com>2017-11-29 01:28:39 -0500
commit78c5e7b90eee10067d39a8ba6588e6b53ba00d82 (patch)
treebd69ad87bc72eea2d2dcf95b3541579b243d5c51 /tests/model_inheritance/tests.py
parent746caf3ef821dbf7588797cb2600fa81b9df9d1d (diff)
Fixed #28834 -- Followed ancestor links on field cache lookup failure.
Thanks Tim for the review.
Diffstat (limited to 'tests/model_inheritance/tests.py')
-rw-r--r--tests/model_inheritance/tests.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/model_inheritance/tests.py b/tests/model_inheritance/tests.py
index 88f1e623c4..ad85a653d5 100644
--- a/tests/model_inheritance/tests.py
+++ b/tests/model_inheritance/tests.py
@@ -368,6 +368,22 @@ class ModelInheritanceDataTests(TestCase):
self.assertEqual(qs[1].italianrestaurant.name, 'Ristorante Miron')
self.assertEqual(qs[1].italianrestaurant.rating, 4)
+ def test_parent_cache_reuse(self):
+ place = Place.objects.create()
+ GrandChild.objects.create(place=place)
+ grand_parent = GrandParent.objects.latest('pk')
+ with self.assertNumQueries(1):
+ self.assertEqual(grand_parent.place, place)
+ parent = grand_parent.parent
+ with self.assertNumQueries(0):
+ self.assertEqual(parent.place, place)
+ child = parent.child
+ with self.assertNumQueries(0):
+ self.assertEqual(child.place, place)
+ grandchild = child.grandchild
+ with self.assertNumQueries(0):
+ self.assertEqual(grandchild.place, place)
+
def test_update_query_counts(self):
"""
Update queries do not generate unnecessary queries (#18304).