Opened 7 years ago

Closed 5 years ago

Last modified 5 years ago

#28658 closed Cleanup/optimization (fixed)

Move DISTINCT handling to the Aggregate base class.

Reported by: Simon Charette Owned by: Simon Charette
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Django ships with a few Aggregate subclasses that expose a distinct kwarg in order to inject a DISTINCT clause on compilation.

Since DISTINCT is repeatedly used by subclasses and likely to be useful for custom Aggregate subclasses (PostgreSQL supports DISTINCT on all aggregate functions, SQLite on all aggregates with a single argument, ...) I suggest we handle it in the Aggregate base class.

We should be able to rely on DatebaseOperations.check_expression_support to prevent distinct=True from being passed to aggregates not supporting it on a backend basis.

Change History (9)

comment:1 by Simon Charette, 7 years ago

Has patch: set
Patch needs improvement: set

comment:2 by Tim Graham, 7 years ago

Triage Stage: UnreviewedAccepted

comment:3 by Simon Charette, 5 years ago

Patch needs improvement: unset

comment:4 by Tim Graham, 5 years ago

Patch needs improvement: set

comment:5 by Simon Charette, 5 years ago

Patch needs improvement: unset

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

Resolution: fixed
Status: assignedclosed

In bc05547:

Fixed #28658 -- Added DISTINCT handling to the Aggregate class.

comment:7 by Claude Paroz, 5 years ago

Regression reported in #30120

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

In 6516e492:

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

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

comment:9 by Tim Graham <timograham@…>, 5 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