aggregation annotations on related tables do not work with ordering on field in different related table
|Reported by:||Koen Biermans <koen.biermans@…>||Owned by:||russellm|
|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)
Changed 6 years ago by Koen Biermans <koen.biermans@…>
comment:1 Changed 6 years ago by russellm
- Needs documentation unset
- Needs tests unset
- Owner changed from nobody to russellm
- Patch needs improvement unset
- Status changed from new to assigned
- Triage Stage changed from Unreviewed to Accepted
- Version changed from 1.0 to SVN
comment:2 Changed 6 years ago by russellm
- Resolution set to fixed
- Status changed from assigned to closed