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

[soc2009/multidb] Merged up to trunk r11009

git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/multidb@11011 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Alex Gaynor
2009-06-16 01:36:05 +00:00
parent 83df1f1056
commit f6db1dd357
11 changed files with 247 additions and 81 deletions

View File

@@ -0,0 +1,22 @@
from django.test import TestCase
from regressiontests.one_to_one_regress.models import Place, UndergroundBar
class OneToOneDeletionTests(TestCase):
def test_reverse_relationship_cache_cascade(self):
"""
Regression test for #9023: accessing the reverse relationship shouldn't
result in a cascading delete().
"""
place = Place.objects.create(name="Dempsey's", address="623 Vermont St")
bar = UndergroundBar.objects.create(place=place, serves_cocktails=False)
# The bug in #9023: if you access the one-to-one relation *before*
# setting to None and deleting, the cascade happens anyway.
place.undergroundbar
bar.place.name='foo'
bar.place = None
bar.save()
place.delete()
self.assertEqual(Place.objects.all().count(), 0)
self.assertEqual(UndergroundBar.objects.all().count(), 1)