提交 9b561ab0 编写于 作者: A Aaron Patterson

avoid calling to_sql when we can

上级 bf2223d0
......@@ -208,12 +208,12 @@ def execute_grouped_calculation(operation, column_name) #:nodoc:
aggregate_alias = column_alias_for(operation, column_name)
select_statement = if operation == 'count' && column_name == :all
"COUNT(*) AS count_all"
["COUNT(*) AS count_all"]
else
Arel::Attribute.new(@klass.unscoped.table, column_name).send(operation).as(aggregate_alias).to_sql
[Arel::Attribute.new(@klass.unscoped.table, column_name).send(operation).as(aggregate_alias)]
end
select_statement << ", #{group_field} AS #{group_alias}"
select_statement << "#{group_field} AS #{group_alias}"
relation = except(:group).select(select_statement).group(group)
......
......@@ -36,7 +36,7 @@ def select(value = Proc.new)
to_a.select {|*block_args| value.call(*block_args) }
else
relation = clone
relation.select_values += [value]
relation.select_values += Array.wrap(value)
relation
end
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册