From 96706d76cdcf78bd5c17d19033a1c05fef0c659d Mon Sep 17 00:00:00 2001 From: David Wobrock Date: Tue, 20 Jul 2021 10:10:27 +0200 Subject: [PATCH] Added more tests for chaining QuerySet.defer() after only(). --- tests/defer/tests.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/defer/tests.py b/tests/defer/tests.py index 4058fadde9..08c67cb5a3 100644 --- a/tests/defer/tests.py +++ b/tests/defer/tests.py @@ -49,9 +49,15 @@ class DeferTests(AssertionMixin, TestCase): qs = Primary.objects.all() self.assert_delayed(qs.only("name", "value").defer("name")[0], 2) self.assert_delayed(qs.defer("name").only("value", "name")[0], 2) + self.assert_delayed(qs.defer('name').only('name').only('value')[0], 2) self.assert_delayed(qs.defer("name").only("value")[0], 2) self.assert_delayed(qs.only("name").defer("value")[0], 2) + def test_defer_only_clear(self): + qs = Primary.objects.all() + self.assert_delayed(qs.only('name').defer('name')[0], 0) + self.assert_delayed(qs.defer('name').only('name')[0], 0) + def test_defer_on_an_already_deferred_field(self): qs = Primary.objects.all() self.assert_delayed(qs.defer("name")[0], 1)