Refs #24020 -- return expressions from get_group_by_cols()

This commit is contained in:
Anssi Kääriäinen 2014-12-18 11:02:43 +02:00 committed by Carl Meyer
parent 9c1f501d7b
commit 4a2a433e7d
2 changed files with 5 additions and 4 deletions

View File

@ -503,7 +503,7 @@ class Col(ExpressionNode):
return self.__class__(relabels.get(self.alias, self.alias), self.target, self.output_field)
def get_group_by_cols(self):
return [(self.alias, self.target.column)]
return [self]
class Ref(ExpressionNode):
@ -529,7 +529,7 @@ class Ref(ExpressionNode):
return "%s" % compiler.quote_name_unless_alias(self.refs), []
def get_group_by_cols(self):
return [(None, self.refs)]
return [self]
class Date(ExpressionNode):

View File

@ -583,10 +583,11 @@ class SQLCompiler(object):
for annotation in self.query.annotation_select.values():
cols = annotation.get_group_by_cols()
for col in cols:
sql = '%s.%s' % (qn(col[0]), qn(col[1]))
if sql not in seen:
sql, col_params = self.compile(col)
if sql not in seen or col_params:
result.append(sql)
seen.add(sql)
params.extend(col_params)
return result, params