Opened 16 years ago
Closed 12 years ago
#12153 closed Bug (fixed)
broken sql-statement with ordering and inheritance chain (posgresql backend)
| Reported by: | Owned by: | nobody | |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | 1.1 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
>> model.py (project tests)<<
# -*- coding: iso-8859-1 -*-
from django.db import models
class A(models.Model):
class Meta:[[BR]]
ordering=('id',)
class B(A):
pass
class C(B):
pass
class D(C):
pass
>> test.py <<
from tests.models import * d=D() d.save()
>> resulting django query <<
SELECT (1) AS "a", "tests_a"."id", "tests_b"."a_ptr_id", "tests_c"."b_ptr_id", "tests_d"."c_ptr_id"
FROM "tests_d"
INNER JOIN "tests_c" ON ("tests_d"."c_ptr_id" = "tests_c"."b_ptr_id")
INNER JOIN "tests_a" ON ("tests_d"."c_ptr_id" = "tests_a"."id")
INNER JOIN "tests_b" ON ("tests_d"."c_ptr_id" = "tests_b"."a_ptr_id")
INNER JOIN "tests_a" T6 ON (T5."a_ptr_id" = T6."id") WHERE "tests_d"."c_ptr_id" = 1 ORDER BY "tests_d"."c_ptr_id" ASC LIMIT 1'
Change History (6)
comment:1 by , 16 years ago
| milestone: | → 1.2 |
|---|---|
| Triage Stage: | Unreviewed → Accepted |
comment:2 by , 16 years ago
| milestone: | 1.2 → 1.3 |
|---|
comment:3 by , 15 years ago
| milestone: | 1.3 |
|---|---|
| Severity: | → Normal |
| Type: | → Bug |
comment:6 by , 12 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Seems to be fixed in master. I believe the problem was that parent joining generated the joins in different direction than filtering. This is tested in master, so not adding any tests.
Note:
See TracTickets
for help on using tickets.
Not critical for 1.2