Opened 5 years ago

Closed 5 years ago

Last modified 4 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:

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

Download all attachments as: .zip

Change History (6)

comment:1 Changed 5 years ago by Alex

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 5 years ago by russellm

  • milestone set to 1.2

Changed 5 years ago by Alex

comment:3 Changed 5 years ago by Alex

  • Has patch set

comment:4 Changed 5 years ago by jkocherhans

  • Resolution set to fixed
  • Status changed from new to closed

Fixed in [12544].

comment:5 Changed 4 years ago by jacob

  • milestone 1.2 deleted

Milestone 1.2 deleted

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