diff options
author | Nick Pope <nick@nickpope.me.uk> | 2022-02-22 09:29:38 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-22 10:29:38 +0100 |
commit | 847f46e9bf88964484c8b76a10af753ea1018311 (patch) | |
tree | 13aced534cbae373f47cce8fce1444ad0e8e01d3 /tests/select_related_regress | |
parent | 7ba6ebe9149ae38257d70100e8bfbfd0da189862 (diff) | |
download | django-847f46e9bf88964484c8b76a10af753ea1018311.tar.gz |
Removed redundant QuerySet.all() calls in docs and tests.
Most QuerySet methods are mapped onto the Manager and, in general,
it isn't necessary to call .all() on the manager.
Diffstat (limited to 'tests/select_related_regress')
-rw-r--r-- | tests/select_related_regress/tests.py | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/tests/select_related_regress/tests.py b/tests/select_related_regress/tests.py index 5ce331d332..94a15bde24 100644 --- a/tests/select_related_regress/tests.py +++ b/tests/select_related_regress/tests.py @@ -92,7 +92,7 @@ class SelectRelatedRegressTests(TestCase): c = Class.objects.create(org=o) Enrollment.objects.create(std=s, cls=c) - e_related = Enrollment.objects.all().select_related()[0] + e_related = Enrollment.objects.select_related()[0] self.assertEqual(e_related.std.person.user.name, "std") self.assertEqual(e_related.cls.org.person.user.name, "org") @@ -228,19 +228,15 @@ class SelectRelatedRegressTests(TestCase): c = C.objects.create( name="c", lots_of_text="lots_of_text_c", is_published=True, c_a=a, c_b=b ) - results = ( - C.objects.all() - .only( - "name", - "lots_of_text", - "c_a", - "c_b", - "c_b__lots_of_text", - "c_a__name", - "c_b__name", - ) - .select_related() - ) + results = C.objects.only( + "name", + "lots_of_text", + "c_a", + "c_b", + "c_b__lots_of_text", + "c_a__name", + "c_b__name", + ).select_related() self.assertSequenceEqual(results, [c]) with self.assertNumQueries(0): qs_c = results[0] |