1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Fixed #25296 -- Prevented model related object cache pollution when create() fails due to an unsaved object.

This commit is contained in:
Raphael Merx
2015-09-16 19:49:40 -07:00
committed by Tim Graham
parent c21410aeeb
commit f5a33e4840
2 changed files with 8 additions and 0 deletions

View File

@@ -135,9 +135,14 @@ class OneToOneTests(TestCase):
should raise an exception.
"""
place = Place(name='User', address='London')
with self.assertRaises(Restaurant.DoesNotExist):
place.restaurant
msg = "save() prohibited to prevent data loss due to unsaved related object 'place'."
with self.assertRaisesMessage(ValueError, msg):
Restaurant.objects.create(place=place, serves_hot_dogs=True, serves_pizza=False)
# place should not cache restaurant
with self.assertRaises(Restaurant.DoesNotExist):
place.restaurant
def test_reverse_relationship_cache_cascade(self):
"""