#13159 closed (fixed)
Quote aggregate alias in order by
Reported by: | David Elias | Owned by: | |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | yes | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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.
Attachments (1)
Change History (7)
by , 15 years ago
Attachment: | quote_aggregate_alias_orderby.patch added |
---|
comment:1 by , 15 years ago
milestone: | 1.2 |
---|---|
Needs tests: | set |
Triage Stage: | Unreviewed → Accepted |
comment:3 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:4 by , 14 years ago
comment:6 by , 12 years ago
Component: | ORM aggregation → Database layer (models, ORM) |
---|
Note:
See TracTickets
for help on using tickets.
Not critical for 1.2. Patch also requires a test case.