Opened 15 years ago

Closed 14 years ago

Last modified 12 years ago

#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)

quote_aggregate_alias_orderby.patch (552 bytes ) - added by David Elias 15 years ago.

Download all attachments as: .zip

Change History (7)

by David Elias, 15 years ago

comment:1 by Russell Keith-Magee, 15 years ago

milestone: 1.2
Needs tests: set
Triage Stage: UnreviewedAccepted

Not critical for 1.2. Patch also requires a test case.

comment:2 by Russell Keith-Magee, 15 years ago

milestone: 1.3

Marking against 1.3 so it isn't forgotten.

comment:3 by Alex Gaynor, 14 years ago

Resolution: fixed
Status: newclosed

(In [15318]) Fixed #13159 -- properly quote aggregates in order_by.

comment:4 by Alex Gaynor, 14 years ago

(In [15319]) [1.2.X] Fixed #13159 -- properly quote aggregates in order_by. Backport of [15318].

comment:5 by Jacob, 13 years ago

milestone: 1.3

Milestone 1.3 deleted

comment:6 by Anssi Kääriäinen, 12 years ago

Component: ORM aggregationDatabase layer (models, ORM)
Note: See TracTickets for help on using tickets.
Back to Top