Refs #24020 -- return expressions from get_group_by_cols()
This commit is contained in:
parent
9c1f501d7b
commit
4a2a433e7d
|
@ -503,7 +503,7 @@ class Col(ExpressionNode):
|
||||||
return self.__class__(relabels.get(self.alias, self.alias), self.target, self.output_field)
|
return self.__class__(relabels.get(self.alias, self.alias), self.target, self.output_field)
|
||||||
|
|
||||||
def get_group_by_cols(self):
|
def get_group_by_cols(self):
|
||||||
return [(self.alias, self.target.column)]
|
return [self]
|
||||||
|
|
||||||
|
|
||||||
class Ref(ExpressionNode):
|
class Ref(ExpressionNode):
|
||||||
|
@ -529,7 +529,7 @@ class Ref(ExpressionNode):
|
||||||
return "%s" % compiler.quote_name_unless_alias(self.refs), []
|
return "%s" % compiler.quote_name_unless_alias(self.refs), []
|
||||||
|
|
||||||
def get_group_by_cols(self):
|
def get_group_by_cols(self):
|
||||||
return [(None, self.refs)]
|
return [self]
|
||||||
|
|
||||||
|
|
||||||
class Date(ExpressionNode):
|
class Date(ExpressionNode):
|
||||||
|
|
|
@ -583,10 +583,11 @@ class SQLCompiler(object):
|
||||||
for annotation in self.query.annotation_select.values():
|
for annotation in self.query.annotation_select.values():
|
||||||
cols = annotation.get_group_by_cols()
|
cols = annotation.get_group_by_cols()
|
||||||
for col in cols:
|
for col in cols:
|
||||||
sql = '%s.%s' % (qn(col[0]), qn(col[1]))
|
sql, col_params = self.compile(col)
|
||||||
if sql not in seen:
|
if sql not in seen or col_params:
|
||||||
result.append(sql)
|
result.append(sql)
|
||||||
seen.add(sql)
|
seen.add(sql)
|
||||||
|
params.extend(col_params)
|
||||||
|
|
||||||
return result, params
|
return result, params
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue