Opened 13 years ago

Closed 13 years ago

#16944 closed Bug (duplicate)

multiple inheritance issue

Reported by: pegler@… Owned by: nobody
Component: Database layer (models, ORM) Version: 1.3
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

Description

Django's support for multiple inheritance from several non-abstract models seems to almost be working. When both parent models have the same name for their PK, saving will update a related row instead of insert a new one.

Scenario:

Model: Pet - pk: id
Model: Mammal - pk: id
Model: Cat - inherits from Pet and Mammal, pk on the 2 foreign keys

Cat.save() will first insert a Pet row, since id isn't yet set. It will then set Cat.id to the new id values from Pet. It will then try to save Mammal, but since id has been set from Pet, it will try to update/insert a Mammal row (instead of always inserting).

The code at fault is here: https://code.djangoproject.com/browser/django/tags/releases/1.3.1/django/db/models/base.py#L492

I am not sure of the best solution for this, but perhaps not setting attributes that are also primary keys of other parent models.

Change History (1)

comment:1 by anonymous, 13 years ago

Resolution: duplicate
Status: newclosed

I think this is #12002.

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