MCPcopy
hub / github.com/django/django / test_subquery_condition

Method test_subquery_condition

tests/queries/tests.py:188–200  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

186 cls.c2 = Cover.objects.create(title="second", item=cls.i2)
187
188 def test_subquery_condition(self):
189 qs1 = Tag.objects.filter(pk__lte=0)
190 qs2 = Tag.objects.filter(parent__in=qs1)
191 qs3 = Tag.objects.filter(parent__in=qs2)
192 self.assertEqual(qs3.query.subq_aliases, {"T", "U", "V"})
193 self.assertIn("v0", str(qs3.query).lower())
194 qs4 = qs3.filter(parent__in=qs1)
195 self.assertEqual(qs4.query.subq_aliases, {"T", "U", "V"})
196 # It is possible to reuse U for the second subquery, no need to use W.
197 self.assertNotIn("w0", str(qs4.query).lower())
198 # So, 'U0."id"' is referenced in SELECT and WHERE twice.
199 id_col = "%s." % connection.ops.quote_name("u0").lower()
200 self.assertEqual(str(qs4.query).lower().count(id_col), 4)
201
202 def test_ticket1050(self):
203 self.assertSequenceEqual(

Callers

nothing calls this directly

Calls 3

filterMethod · 0.45
quote_nameMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected