#12731 closed (fixed)
Manager.raw() doesn't work with Multi-table inheritance
| Reported by: | 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)
Change History (6)
comment:1 by , 16 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:2 by , 16 years ago
| milestone: | → 1.2 |
|---|
by , 16 years ago
| Attachment: | django-raw-inheritance.diff added |
|---|
comment:3 by , 16 years ago
| Has patch: | set |
|---|
comment:4 by , 16 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Fixed in [12544].