Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#12731 closed (fixed)

Manager.raw() doesn't work with Multi-table inheritance

Reported by: eric.buckley@… Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Keywords: raw
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


As far as I can tell the Manager.raw() function does not work with a subclassed model. I believe the raw function is looking for an 'id' field, and this does not exist in a subclassed table (instead of id, there is a <parent>_ptr_id field).


class Parent(models.Model)
 name = models.CharField(max_length=50)

class Child(Parent)
 favorite_toy = models.CharField(max_length=50)

# broken code
Child.objects.raw("SELECT * FROM child")

Attachments (1)

django-raw-inheritance.diff (2.1 KB) - added by Alex Gaynor 8 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 Changed 8 years ago by Alex Gaynor

Triage Stage: UnreviewedAccepted

comment:2 Changed 8 years ago by Russell Keith-Magee

milestone: 1.2

Changed 8 years ago by Alex Gaynor

Attachment: django-raw-inheritance.diff added

comment:3 Changed 8 years ago by Alex Gaynor

Has patch: set

comment:4 Changed 8 years ago by jkocherhans

Resolution: fixed
Status: newclosed

Fixed in [12544].

comment:5 Changed 7 years ago by Jacob

milestone: 1.2

Milestone 1.2 deleted

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