Opened 3 years ago

Closed 3 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: UI/UX:


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 3 years ago.

Download all attachments as: .zip

Change History (2)

Changed 3 years ago by Gregory

comment:1 Changed 3 years ago by russellm

  • milestone 1.3 deleted
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.