#26195: order_by pk doesn't work in multi-table inheritance models if parent has
default ordering
-------------------------------------+-------------------------------------
Reporter: ris | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.9
(models, ORM) | Keywords: multi table inheritance
Severity: Normal | order_by MTI pk
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Using django 1.9.2, given the example models.py:
{{{
class ModelA ( models.Model ):
class Meta ( object ):
ordering = ("x",)
x = models.TextField ()
class ModelB ( ModelA ):
pass
}}}
The following query should order by `modela_ptr_id`:
{{{
>>> str ( ModelB.objects.order_by ( "pk" ).query )
'SELECT "dummy_modela"."id", "dummy_modela"."x",
"dummy_modelb"."modela_ptr_id" FROM "dummy_modelb" INNER JOIN
"dummy_modela" ON ( "dummy_modelb"."modela_ptr_id" = "dummy_modela"."id" )
ORDER BY "dummy_modela"."x" ASC'
}}}
But doesn't, instead falling back to `ModelA`'s default.
This is particularly annoying as it prevents you from doing a `.distinct (
"pk" ).order_by ( "pk" )`
--
Ticket URL: <https://code.djangoproject.com/ticket/26195>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/046.021006d4bebd7fc106773fff09c1e7b4%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.