﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
13159	Quote aggregate alias in order by	David Elias		"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.
"		closed	Database layer (models, ORM)	dev		fixed			Accepted	1	0	1	0	0	0
