Opened 4 years ago

Closed 4 years ago

#19465 closed Bug (duplicate)

Virtual Base Classes Not Implemented

Reported by: steven_ganz Owned by: nobody
Component: Uncategorized Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


This model involving the standard "diamond" multiple inheritance hierarchy:

from django.db import models

class A(models.Model):
    name = models.CharField(max_length=256)
    class Meta:
        abstract = True

class B(A):
    class Meta:
        abstract = True

class C(A):
    class Meta:
        abstract = True

class D(B, C):

generates the sql:

CREATE TABLE `teamBuilderWebVersion_d` (
    `name` varchar(256) NOT NULL,
    `name` varchar(256) NOT NULL

which triggers the error:

django.db.utils.DatabaseError: (1060, "Duplicate column name 'name'")

So it seems that although python considers there to be only one instance of a base class inherited twice, django considers there to be two.

Change History (1)

comment:1 Changed 4 years ago by Preston Holmes

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Resolution: duplicate
Status: newclosed

This appears to be a more straightforward version of #15279 as that ticket demonstrated the same bug, but with related fields - your issue demonstrates it is with any field

Note: See TracTickets for help on using tickets.
Back to Top