summaryrefslogtreecommitdiff
path: root/tests/defer
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2022-08-18 12:30:20 -0400
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-08-30 08:43:53 +0200
commitb3db6c8dcb5145f7d45eff517bcd96460475c879 (patch)
treeca51349fab4db9de0f86dcb315c24caa02ae1e2a /tests/defer
parent5d12650ed9269acb3cba97fd70e8df2e35a55a54 (diff)
Fixed #21204 -- Tracked field deferrals by field instead of models.
This ensures field deferral works properly when a model is involved more than once in the same query with a distinct deferral mask.
Diffstat (limited to 'tests/defer')
-rw-r--r--tests/defer/tests.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/defer/tests.py b/tests/defer/tests.py
index fe9637c7f1..c2319b54ec 100644
--- a/tests/defer/tests.py
+++ b/tests/defer/tests.py
@@ -290,6 +290,8 @@ class InvalidDeferTests(SimpleTestCase):
msg = "Primary has no field named 'missing'"
with self.assertRaisesMessage(FieldDoesNotExist, msg):
list(Primary.objects.defer("missing"))
+ with self.assertRaisesMessage(FieldError, "missing"):
+ list(Primary.objects.defer("value__missing"))
msg = "Secondary has no field named 'missing'"
with self.assertRaisesMessage(FieldDoesNotExist, msg):
list(Primary.objects.defer("related__missing"))
@@ -298,6 +300,8 @@ class InvalidDeferTests(SimpleTestCase):
msg = "Primary has no field named 'missing'"
with self.assertRaisesMessage(FieldDoesNotExist, msg):
list(Primary.objects.only("missing"))
+ with self.assertRaisesMessage(FieldError, "missing"):
+ list(Primary.objects.only("value__missing"))
msg = "Secondary has no field named 'missing'"
with self.assertRaisesMessage(FieldDoesNotExist, msg):
list(Primary.objects.only("related__missing"))