Opened 8 months ago

Last modified 8 months ago

#28658 assigned Cleanup/optimization

Move DISTINCT handling to the Aggregate base class.

Reported by: Simon Charette Owned by: Simon Charette
Component: Database layer (models, ORM) Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
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 (2)

comment:1 Changed 8 months ago by Simon Charette

Has patch: set
Patch needs improvement: set

comment:2 Changed 8 months ago by Tim Graham

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