﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
18083	Multi-table inheritance subclasses proxy deletion is broken	Simon Charette	Simon Charette	"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."	Bug	closed	Database layer (models, ORM)	1.4	Normal	fixed	model proxy multi-table inheritance signals		Accepted	1	0	0	0	0	0
