Opened 15 years ago

Closed 11 years ago

#12153 closed Bug (fixed)

broken sql-statement with ordering and inheritance chain (posgresql backend)

Reported by: zegrep@… 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 Russell Keith-Magee, 15 years ago

milestone: 1.2
Triage Stage: UnreviewedAccepted

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

milestone: 1.21.3

Not critical for 1.2

comment:3 by Matt McClanahan, 14 years ago

milestone: 1.3
Severity: Normal
Type: Bug

comment:4 by Aymeric Augustin, 13 years ago

UI/UX: unset

Change UI/UX from NULL to False.

comment:5 by Aymeric Augustin, 13 years ago

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:6 by Anssi Kääriäinen, 11 years ago

Resolution: fixed
Status: newclosed

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.
Back to Top