[patch] order_by on related table with db_column different to name fails
|Reported by:||Owned by:||Adrian Holovaty|
|Component:||Database layer (models, ORM)||Version:||master|
|Cc:||bs1984@…, russell@…, gary.wilson@…, real.human@…, arthur.case@…||Triage Stage:||Accepted|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
When ordering by a related table which has a db_column different to the field name, and ordering by the field name, incorrect SQL is generated.
This bug is on line 483 of django/db/models/query.py (r3189) -- it incorrectly uses the opts of the main table, not the related table in the call to orderfield2column(). This shows up in the admin interface, when sorting by a related field.
I do not know the correct fix for this bug.
Change History (27)
comment:5 Changed 11 years ago by
|Summary:||order_by on related table with db_column different to name fails → [patch] order_by on related table with db_column different to name fails|
comment:20 Changed 10 years ago by
|Patch needs improvement:||unset|
|Triage Stage:||Accepted → Unreviewed|