In-bulk does correctly prefetch objects by not using .iterator() directly.
(self)
| 1576 | self.assertEqual(co_serfs, co_serfs2) |
| 1577 | |
| 1578 | def test_in_bulk(self): |
| 1579 | """ |
| 1580 | In-bulk does correctly prefetch objects by not using .iterator() |
| 1581 | directly. |
| 1582 | """ |
| 1583 | boss1 = Employee.objects.create(name="Peter") |
| 1584 | boss2 = Employee.objects.create(name="Jack") |
| 1585 | with self.assertNumQueries(2): |
| 1586 | # Prefetch is done and it does not cause any errors. |
| 1587 | bulk = Employee.objects.prefetch_related("serfs").in_bulk( |
| 1588 | [boss1.pk, boss2.pk] |
| 1589 | ) |
| 1590 | for b in bulk.values(): |
| 1591 | list(b.serfs.all()) |
| 1592 | |
| 1593 | |
| 1594 | class MultiDbTests(TestCase): |
nothing calls this directly
no test coverage detected