Opened 7 years ago

Closed 3 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


>> (project tests)<<

# -*- coding: iso-8859-1 -*-
from django.db import models

class A(models.Model):
    class Meta:[[BR]]
class B(A): 
class C(B): 
class D(C):

>> <<

from tests.models import *

>> 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 Changed 7 years ago by russellm

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

comment:2 Changed 6 years ago by russellm

  • milestone changed from 1.2 to 1.3

Not critical for 1.2

comment:3 Changed 5 years ago by mattmcc

  • milestone 1.3 deleted
  • Severity set to Normal
  • Type set to Bug

comment:4 Changed 5 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:5 Changed 5 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

comment:6 Changed 3 years ago by akaariai

  • Resolution set to fixed
  • Status changed from new to 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.
Back to Top