| 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 | |
| 1391 | class Queries2Tests(TestCase): |