Opened 14 years ago

Closed 14 years ago

Last modified 13 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: dev
Severity: Keywords: raw
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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).

example:

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 14 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 by Alex Gaynor, 14 years ago

Triage Stage: UnreviewedAccepted

comment:2 by Russell Keith-Magee, 14 years ago

milestone: 1.2

by Alex Gaynor, 14 years ago

Attachment: django-raw-inheritance.diff added

comment:3 by Alex Gaynor, 14 years ago

Has patch: set

comment:4 by jkocherhans, 14 years ago

Resolution: fixed
Status: newclosed

Fixed in [12544].

comment:5 by Jacob, 13 years ago

milestone: 1.2

Milestone 1.2 deleted

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