aggregation annotations on related tables do not work with ordering on field in different related table
|Reported by:||Owned by:||Russell Keith-Magee|
|Component:||Database layer (models, ORM)||Version:||master|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Using annotate on a related table in combination with ordering on a field from a different related table results in failures.
There seem to be two problems:
- the related orderby field is not included in the GROUP BY, which does not work on Postgres
- the related table (of the orderby field) is included with an inner join, which comes after the left outer join of the annotation tables, which leads to incorrect results.
This is easier to explain with an example, so I am including a diff that contains a small testcase demonstrating the problem.
Change History (7)
comment:1 Changed 8 years ago by
|Owner:||changed from nobody to Russell Keith-Magee|
|Patch needs improvement:||unset|
|Status:||new → assigned|
|Triage Stage:||Unreviewed → Accepted|
|Version:||1.0 → SVN|