Changes between Initial Version and Version 1 of Ticket #26434, comment 11


Ignore:
Timestamp:
Jun 10, 2019, 9:39:45 AM (5 years ago)
Author:
Can Sarıgöl

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #26434, comment 11

    initial v1  
    1 I want to discuss when collecting group by columns why are order by columns added into extensions.
    2 
    3 For example:
    4 Model.objects.values("col_a").annotate(max=Max("col_b")).order_by('col_c')
    5 current query:
    6 
    7 
    8 {{{
    9 select col_a, MAX(col_b) as max
    10 from Model
    11 group by col_a, col_c
    12 order by col_c
    13 }}}
    14 
    15 I think the expected behavior has should be like that:
    16 django.db.utils.ProgrammingError: column "Model.col_c" must appear in the GROUP BY clause or be used in an aggregate function
    17 
    18 Because this behavior changes my group by and result. if I'm lucky, my result doesn't change.
    19 
    20 If we check test_annotation_with_value, 'name' column is being added into group_by because Book model has Meta.ordering.
Back to Top