summaryrefslogtreecommitdiff
path: root/tests/contenttypes_tests
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/contenttypes_tests
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/contenttypes_tests')
-rw-r--r--tests/contenttypes_tests/test_fields.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/contenttypes_tests/test_fields.py b/tests/contenttypes_tests/test_fields.py
index ab16324fb6..fc49d59b27 100644
--- a/tests/contenttypes_tests/test_fields.py
+++ b/tests/contenttypes_tests/test_fields.py
@@ -57,6 +57,15 @@ class GenericForeignKeyTests(TestCase):
self.assertIsNot(answer.question, old_question_obj)
self.assertEqual(answer.question, old_question_obj)
+ def test_clear_cached_generic_relation_when_deferred(self):
+ question = Question.objects.create(text="question")
+ Answer.objects.create(text="answer", question=question)
+ answer = Answer.objects.defer("text").get()
+ old_question_obj = answer.question
+ # The reverse relation is refreshed even when the text field is deferred.
+ answer.refresh_from_db()
+ self.assertIsNot(answer.question, old_question_obj)
+
class GenericRelationTests(TestCase):
def test_value_to_string(self):