summaryrefslogtreecommitdiff
path: root/tests/defer/tests.py
diff options
context:
space:
mode:
authorAdam Johnson <me@adamj.eu>2024-11-30 08:03:55 +0000
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2024-12-02 16:01:37 +0100
commit2f6b096b83c55317c7ceef2d8d5dc3bee33293dc (patch)
tree7d17909df90c690f26dcda0eaa6b7fb0b54fd35b /tests/defer/tests.py
parent32b9e00b0c74b3af77c25215e2e2d1254b995355 (diff)
Fixed #35950 -- Restored refreshing of relations when fields deferred.
Thank you to Simon Charette and Sarah Boyce for the review. Regression in 73df8b54a2fab53bec4c7573cda5ad8c869c2fd8.
Diffstat (limited to 'tests/defer/tests.py')
-rw-r--r--tests/defer/tests.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/defer/tests.py b/tests/defer/tests.py
index 3945b667ba..989b5c63d7 100644
--- a/tests/defer/tests.py
+++ b/tests/defer/tests.py
@@ -290,6 +290,14 @@ class TestDefer2(AssertionMixin, TestCase):
self.assertEqual(rf2.name, "new foo")
self.assertEqual(rf2.value, "new bar")
+ def test_refresh_when_one_field_deferred(self):
+ s = Secondary.objects.create()
+ PrimaryOneToOne.objects.create(name="foo", value="bar", related=s)
+ s = Secondary.objects.defer("first").get()
+ p_before = s.primary_o2o
+ s.refresh_from_db()
+ self.assertIsNot(s.primary_o2o, p_before)
+
class InvalidDeferTests(SimpleTestCase):
def test_invalid_defer(self):