﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
12153	broken sql-statement with ordering and inheritance chain (posgresql backend)	zegrep@…	nobody	"
'''>> 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'
}}}


"	Bug	closed	Database layer (models, ORM)	1.1	Normal	fixed			Accepted	0	0	0	0	0	0
