Opened 11 years ago
Closed 11 years ago
#21159 closed New feature (duplicate)
Ability to do .distinct() on extra select columns
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.5 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Hi all,
It would be nice to be able to use columns defined in .extra ( select = ... ) as fields in .distinct (). As it is, SQLCompiler.get_distinct () ends up calling ._setup_joins () on all fields, which fails. SQLCompiler.get_ordering (), on the other hand seems to have a mechanism to cope with extra columns.
Currently I use a hacked custom SQLCompiler for this but it would be nice if I didn't have to.
Note:
See TracTickets
for help on using tickets.
Probably a duplicate of #19434 -- 'Some QuerySet methods not aware of fields added on "extra"'. I've added a note about this to that ticket.