MCPcopy
hub / github.com/django/django / test_union_values_subquery

Method test_union_values_subquery

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

Source from the content-addressed store, hash-verified

1378
1379 @skipUnlessDBFeature("supports_select_union")
1380 def test_union_values_subquery(self):
1381 items = Item.objects.filter(creator=OuterRef("pk"))
1382 item_authors = Author.objects.annotate(is_creator=Exists(items)).order_by()
1383 reports = Report.objects.filter(creator=OuterRef("pk"))
1384 report_authors = Author.objects.annotate(is_creator=Exists(reports)).order_by()
1385 all_authors = item_authors.union(report_authors).order_by("is_creator")
1386 self.assertEqual(
1387 list(all_authors.values_list("is_creator", flat=True)), [False, True]
1388 )
1389
1390
1391class Queries2Tests(TestCase):

Callers

nothing calls this directly

Calls 7

OuterRefClass · 0.90
ExistsClass · 0.90
order_byMethod · 0.80
annotateMethod · 0.80
values_listMethod · 0.80
filterMethod · 0.45
unionMethod · 0.45

Tested by

no test coverage detected