#18083: Multi-table inheritance subclasses proxy deletion is broken
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.4
(models, ORM) | Keywords: model proxy multi-table
Severity: Normal | inheritance
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Given the following models
{{{#!python
#test_app/models.py
from django.db import models
class A(models.Model):
pass
class B(A):
pass
class C(B):
class Meta:
proxy = True
}}}
Running the following tests fails
{{{#!python
#test_app/tests.py
from django.test import TestCase
from .models import *
class SimpleTest(TestCase):
def test_model_subclass_proxy_deletion(self):
c = C.objects.create()
self.assertEqual(1, C.objects.count())
self.assertEqual(1, B.objects.count())
self.assertEqual(1, A.objects.count())
c.delete()
self.assertEqual(0, C.objects.count())
self.assertEqual(0, B.objects.count())
self.assertEqual(0, A.objects.count())
def test_model_subclass_deletion(self):
b = B.objects.create()
self.assertEqual(1, C.objects.count())
self.assertEqual(1, B.objects.count())
self.assertEqual(1, A.objects.count())
b.delete()
self.assertEqual(0, C.objects.count())
self.assertEqual(0, B.objects.count())
self.assertEqual(0, A.objects.count())
}}}
{{{
simon@simon-laptop:~/Bureau/test_deletion$ ./manage.py test test_app
Creating test database for alias 'default'...
.F
======================================================================
FAIL: test_model_subclass_proxy_deletion (test_app.tests.SimpleTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/simon/Bureau/test_deletion/test_app/tests.py", line 27, in
test_model_subclass_proxy_deletion
self.assertEqual(0, A.objects.count())
AssertionError: 0 != 1
----------------------------------------------------------------------
Ran 2 tests in 0.014s
FAILED (failures=1)
Destroying test database for alias 'default'...
}}}
Deleting a multi-table inherited model proxy do not delete all related
parent instances while doing it on the concrete model works perfectly.
--
Ticket URL: <https://code.djangoproject.com/ticket/18083>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.