Opened 8 years ago

Closed 7 years ago

Last modified 5 years ago

#10237 closed (fixed)

Symmetry is lost when inheriting a self-referential m2m field

Reported by: Justin Lilly Owned by: Justin Lilly
Component: Database layer (models, ORM) Version: 1.0
Severity: Keywords: mti, m2m, inheritance
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

When extending a model (via MTI, not ABC), the implicit symmetrical=True reference wasn't being maintained because the current class was being checked against the parent (which weren't the same type). By changing this to an isinstance call instead of a __class__ comparison, it properly compares to parent objects.

Attachments (1)

m2m-inheritance.diff (2.2 KB) - added by Justin Lilly 8 years ago.
Contains a fix and regression tests for the reported bug.

Download all attachments as: .zip

Change History (5)

Changed 8 years ago by Justin Lilly

Attachment: m2m-inheritance.diff added

Contains a fix and regression tests for the reported bug.

comment:1 Changed 8 years ago by Alex Gaynor

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedAccepted

Patch applies and works correctly for me, seems to solve the problem correctly(that code was originally from way back to magic-removal).

comment:2 Changed 8 years ago by Jacob

milestone: 1.1

comment:3 Changed 7 years ago by Russell Keith-Magee

Resolution: fixed
Status: newclosed

(In [10550]) Fixed #10237 -- Corrected the handling of self-referential m2m fields when using multi-table inheritance. Thanks to Justin Lilly for the report and patch.

comment:4 Changed 5 years ago by Jacob

milestone: 1.1

Milestone 1.1 deleted

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