mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
[2.0.x] Fixed #28742 -- Fixed AttributeError crash when assigning None to cached reverse relations.
Backport of fcfcf8aae4 from master
This commit is contained in:
@@ -196,6 +196,15 @@ class OneToOneTests(TestCase):
|
||||
# UndergroundBar.
|
||||
p.undergroundbar = None
|
||||
|
||||
def test_assign_none_to_null_cached_reverse_relation(self):
|
||||
p = Place.objects.get(name='Demon Dogs')
|
||||
# Prime the relation's cache with a value of None.
|
||||
with self.assertRaises(Place.undergroundbar.RelatedObjectDoesNotExist):
|
||||
getattr(p, 'undergroundbar')
|
||||
# Assigning None works if there isn't a related UndergroundBar and the
|
||||
# reverse cache has a value of None.
|
||||
p.undergroundbar = None
|
||||
|
||||
def test_related_object_cache(self):
|
||||
""" Regression test for #6886 (the related-object cache) """
|
||||
|
||||
|
||||
Reference in New Issue
Block a user