diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-06-29 09:41:35 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-06-29 09:41:35 +0000 |
| commit | 493163963633e9746a1eaf84bc39c574e4432eb2 (patch) | |
| tree | e7c5cb9887dfc33ed138fc6539c132e7772ceff2 /tests | |
| parent | 2c1d6a80b34c3f38f474f1c56631a11957153bd2 (diff) | |
Fixed #7276 -- Delete multi-table objects correctly.
When model inheritance is used, the parent objects should be deleted as part of
the delete() call on the child.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7784 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/regressiontests/model_inheritance_regress/models.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/regressiontests/model_inheritance_regress/models.py b/tests/regressiontests/model_inheritance_regress/models.py index 33e2e0e4f6..24d6186150 100644 --- a/tests/regressiontests/model_inheritance_regress/models.py +++ b/tests/regressiontests/model_inheritance_regress/models.py @@ -131,4 +131,26 @@ __test__ = {'API_TESTS':""" >>> Child.objects.dates('created', 'month') [datetime.datetime(2008, 6, 1, 0, 0)] +# Regression test for #7276: calling delete() on a model with multi-table +# inheritance should delete the associated rows from any ancestor tables, as +# well as any descendent objects. + +>>> ident = ItalianRestaurant.objects.all()[0].id +>>> Place.objects.get(pk=ident) +<Place: Guido's All New House of Pasta the place> +>>> xx = Restaurant.objects.create(name='a', address='xx', serves_hot_dogs=True, serves_pizza=False) + +# This should delete both Restuarants, plus the related places, plus the ItalianRestaurant. +>>> Restaurant.objects.all().delete() + +>>> Place.objects.get(pk=ident) +Traceback (most recent call last): +... +DoesNotExist: Place matching query does not exist. + +>>> ItalianRestaurant.objects.get(pk=ident) +Traceback (most recent call last): +... +DoesNotExist: ItalianRestaurant matching query does not exist. + """} |
