Opened 5 years ago

Closed 5 years ago

#21159 closed New feature (duplicate)

Ability to do .distinct() on extra select columns

Reported by: bugs@… 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


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.

Change History (1)

comment:1 Changed 5 years ago by Tim Graham

Resolution: duplicate
Status: newclosed

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.

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