diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-09-28 10:37:35 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-09-28 10:37:35 -0700 |
commit | 9b561ab029f56f3bea61700ffcc7c5c0dd763d25 (patch) | |
tree | d70be95858caa637922abba13ee52ae7e3d26bbf /activerecord | |
parent | bf2223d0e0a5562fb2e946abca4289953134cb77 (diff) | |
download | rails-9b561ab029f56f3bea61700ffcc7c5c0dd763d25.tar.gz rails-9b561ab029f56f3bea61700ffcc7c5c0dd763d25.tar.bz2 rails-9b561ab029f56f3bea61700ffcc7c5c0dd763d25.zip |
avoid calling to_sql when we can
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/relation/calculations.rb | 6 | ||||
-rw-r--r-- | activerecord/lib/active_record/relation/query_methods.rb | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb index 63689ed925..86b89c741d 100644 --- a/activerecord/lib/active_record/relation/calculations.rb +++ b/activerecord/lib/active_record/relation/calculations.rb @@ -208,12 +208,12 @@ module ActiveRecord 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) diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index b8cfdb54e5..b9957c41fa 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -36,7 +36,7 @@ module ActiveRecord 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 |