1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Refs #34570 -- Added extra tests for QuerySet.only() noops.

This commit is contained in:
Simon Charette 2023-05-31 18:23:51 -04:00 committed by Mariusz Felisiak
parent 4142739af1
commit d9e7018796

View File

@ -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]