Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#30120 closed Bug (fixed)

Query syntax error with condition and distinct combination

Reported by: Claude Paroz Owned by: Simon Charette
Component: Database layer (models, ORM) Version: 2.2
Severity: Release blocker Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

A Count annotation containing both a Case condition and a distinct=True param produces a query error on Django 2.2 (whatever the db backend). A space is missing at least (... COUNT(DISTINCTCASE WHEN ...).

Attachments (1)

query_test.diff (1019 bytes ) - added by Claude Paroz 6 years ago.
Failing test example

Download all attachments as: .zip

Change History (7)

by Claude Paroz, 6 years ago

Attachment: query_test.diff added

Failing test example

comment:1 by Claude Paroz, 6 years ago

Bisected to [bc05547cd8c1dd511c6b6a6c873a1bc63417b111] Fixed #28658 -- Added DISTINCT handling to the Aggregate class.

comment:2 by Simon Charette, 6 years ago

Owner: changed from nobody to Simon Charette
Status: newassigned
Triage Stage: UnreviewedAccepted

comment:3 by Simon Charette, 6 years ago

Has patch: set

comment:4 by Claude Paroz, 6 years ago

Triage Stage: AcceptedReady for checkin

Thanks for the quick fix!

comment:5 by Tim Graham <timograham@…>, 6 years ago

Resolution: fixed
Status: assignedclosed

In 6516e492:

[2.2.x] Fixed #30120 -- Fixed invalid SQL in distinct aggregate.

Regression in bc05547cd8c1dd511c6b6a6c873a1bc63417b111 (refs #28658).
Backport of 65858119d23e37872505a4476e7141c33981fb50 from master.

comment:6 by Tim Graham <timograham@…>, 6 years ago

In 65858119:

Fixed #30120 -- Fixed invalid SQL in distinct aggregate.

Regression in bc05547cd8c1dd511c6b6a6c873a1bc63417b111 (refs #28658).

Note: See TracTickets for help on using tickets.
Back to Top