diff --git a/tests/defer_regress/tests.py b/tests/defer_regress/tests.py index fc2d87e12b..5b8a9367da 100644 --- a/tests/defer_regress/tests.py +++ b/tests/defer_regress/tests.py @@ -277,6 +277,28 @@ class DeferRegressionTest(TestCase): with self.assertNumQueries(1): self.assertEqual(Request.objects.defer("items").get(), request) + def test_only_many_to_many_ignored(self): + location = Location.objects.create() + request = Request.objects.create(location=location) + with self.assertNumQueries(1): + self.assertEqual(Request.objects.only("items").get(), request) + + def test_defer_reverse_many_to_many_ignored(self): + location = Location.objects.create() + request = Request.objects.create(location=location) + item = Item.objects.create(value=1) + request.items.add(item) + with self.assertNumQueries(1): + self.assertEqual(Item.objects.defer("request").get(), item) + + def test_only_reverse_many_to_many_ignored(self): + location = Location.objects.create() + request = Request.objects.create(location=location) + item = Item.objects.create(value=1) + request.items.add(item) + with self.assertNumQueries(1): + self.assertEqual(Item.objects.only("request").get(), item) + class DeferDeletionSignalsTests(TestCase): senders = [Item, Proxy]