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:
parent
4142739af1
commit
d9e7018796
@ -277,6 +277,28 @@ class DeferRegressionTest(TestCase):
|
|||||||
with self.assertNumQueries(1):
|
with self.assertNumQueries(1):
|
||||||
self.assertEqual(Request.objects.defer("items").get(), request)
|
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):
|
class DeferDeletionSignalsTests(TestCase):
|
||||||
senders = [Item, Proxy]
|
senders = [Item, Proxy]
|
||||||
|
Loading…
Reference in New Issue
Block a user