Opened 8 years ago

Closed 8 years ago

#14657 closed (invalid)

Extra select fields are merged into 'GROUP BY'

Reported by: Gregory Owned by: nobody
Component: Database layer (models, ORM) Version: 1.2
Severity: Keywords: extra_select,
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Fields are merged into 'GROUP BY', when using some extra select fields and query.group_by attribute.

        fragments = Fragment.objects.all().extra(
            select = {'au_names': 'GROUP_CONCAT(lib_author.surnames ORDER BY names DESC SEPARATOR ", ")'},
        fragments.query.group_by = ['']
        fragments.query.join((None, 'lib_fragment', None, None))

        connection = (
        fragments.query.join(connection, promote=True)

        connection = (
        fragments.query.join(connection, promote=True)
    (GROUP_CONCAT(lib_author.surnames ORDER BY names DESC SEPARATOR ", ")) AS `au_ids`, 
FROM `lib_fragment` 
    LEFT OUTER JOIN `lib_fragment_authors` ON (`lib_fragment`.`id` = `lib_fragment_authors`.`fragment_id`) 
    LEFT OUTER JOIN `lib_author` ON (`lib_fragment_authors`.`author_id` = `lib_author`.`id`) 
GROUP BY (, (GROUP_CONCAT(lib_author.surnames ORDER BY names DESC SEPARATOR ", ")) 
ORDER BY `lib_fragment`.`id`

Attachments (1)

extra_select.diff (735 bytes) - added by Gregory 8 years ago.

Download all attachments as: .zip

Change History (2)

Changed 8 years ago by Gregory

Attachment: extra_select.diff added

comment:1 Changed 8 years ago by Russell Keith-Magee

milestone: 1.3
Resolution: invalid
Status: newclosed

qs.query.group_by (in fact, the entire qs.query structure) is an internal implementation detail. It isn't designed to be modified by end users. We don't (and won't) make any guarantees about how qs.query.group_by interacts with any other part of a query. We don't even guarantee that it will continue to exist.

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