#27632: Oracle backend fails to execute a query with an aggregation that 
contains
an expression in the GROUP BY.
-------------------------------------+-------------------------------------
     Reporter:  Josh Smeaton         |                    Owner:  felixxm
         Type:  Bug                  |                   Status:  assigned
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  oracle               |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Josh Smeaton):

 I didn't actually know that rule, but it totally makes sense. You've
 grouped by that value, so you can use it how you will. If that's the case,
 then shouldn't we just need to extract the `col` references from any
 expressions that we need to group by? Ultimately, the expression doesn't
 matter, just the columns an expression may reference. Indeed, by not
 including the base expression in the set returned by get_group_by_cols,
 the test passes.

 {{{
 diff --git a/django/db/models/expressions.py
 b/django/db/models/expressions.py
 index 20268ee660..46fb86ea21 100644
 --- a/django/db/models/expressions.py
 +++ b/django/db/models/expressions.py
 @@ -323,8 +323,6 @@ class BaseExpression(object):
          return False, ()

      def get_group_by_cols(self):
 -        if not self.contains_aggregate:
 -            return [self]
          cols = []
          for source in self.get_source_expressions():
              cols.extend(source.get_group_by_cols())
 }}}

 I haven't tested this thoroughly, but the aggregation,
 aggregation_regress, and expressions test modules complete successfully.

--
Ticket URL: <https://code.djangoproject.com/ticket/27632#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.900bb2296bd49d8dfc34ffb512db203e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to