Quote aggregate alias in order by
|Reported by:||davidelias||Owned by:|
|Component:||Database layer (models, ORM)||Version:||master|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||yes||Patch needs improvement:||no|
Running the aggregation tests gives an error against Firebird database.
>>> qs = Book.objects.values_list('price').annotate(count=Count('price')).order_by('-count', 'price')
Produces the following sql:
SELECT "AGGREGATION_BOOK"."PRICE", COUNT("AGGREGATION_BOOK"."PRICE") AS "COUNT" FROM "AGGREGATION_BOOK" GROUP BY "AGGREGATION_BOOK"."PRICE" ORDER BY count DESC, "AGGREGATION_BOOK"."PRICE" ASC
count in order by clause is not quoted and clashed with reserved the corresponding reserved word.
Tested the patch against MySQL and SQLite.
Change History (7)
Changed 6 years ago by davidelias
comment:1 Changed 6 years ago by russellm
- milestone 1.2 deleted
- Needs documentation unset
- Needs tests set
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Accepted