summaryrefslogtreecommitdiff
path: root/tests/model_inheritance_regress
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2015-10-02 19:53:50 -0400
committerTim Graham <timograham@gmail.com>2015-10-03 08:29:07 -0400
commitfa2e1e633ac2073906ed3f1f32107d02331107aa (patch)
tree4267b9dd5dc98997033f150b4db668229bf7b7b6 /tests/model_inheritance_regress
parent41ed6338a40240112f242d76970bfa473da2209f (diff)
downloaddjango-fa2e1e633ac2073906ed3f1f32107d02331107aa.tar.gz
Refs #15844 -- Added tests for multi-table inheritance related object filtering efficiency.
Fixed in 97774429aeb54df4c09895c07cd1b09e70201f7d.
Diffstat (limited to 'tests/model_inheritance_regress')
-rw-r--r--tests/model_inheritance_regress/tests.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/model_inheritance_regress/tests.py b/tests/model_inheritance_regress/tests.py
index e04fb18e94..7dc73b6de5 100644
--- a/tests/model_inheritance_regress/tests.py
+++ b/tests/model_inheritance_regress/tests.py
@@ -493,3 +493,22 @@ class ModelInheritanceTest(TestCase):
jane = Supplier.objects.order_by("name").select_related("restaurant")[0]
self.assertEqual(jane.restaurant.name, "Craft")
+
+ def test_related_filtering_query_efficiency_ticket_15844(self):
+ r = Restaurant.objects.create(
+ name="Guido's House of Pasta",
+ address='944 W. Fullerton',
+ serves_hot_dogs=True,
+ serves_pizza=False,
+ )
+ s = Supplier.objects.create(restaurant=r)
+ with self.assertNumQueries(1):
+ self.assertQuerysetEqual(
+ Supplier.objects.filter(restaurant=r),
+ [s], lambda x: x,
+ )
+ with self.assertNumQueries(1):
+ self.assertQuerysetEqual(
+ r.supplier_set.all(),
+ [s], lambda x: x,
+ )