#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

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.

Change History (1)

comment:1 Changed 21 months ago by timo

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

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