diff options
author | Emilio Tagua <miloops@gmail.com> | 2009-08-18 14:10:03 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2009-08-18 14:10:03 -0300 |
commit | 66fbcc1de646129a3fc7415aa2f8416ef78d8cbb (patch) | |
tree | 58012f2b522159e34a6a751b2584e24f1d3ca05a /activerecord/lib/active_record/calculations.rb | |
parent | ac03bc91dbee36233e061eb624f7781a49ab6fcf (diff) | |
download | rails-66fbcc1de646129a3fc7415aa2f8416ef78d8cbb.tar.gz rails-66fbcc1de646129a3fc7415aa2f8416ef78d8cbb.tar.bz2 rails-66fbcc1de646129a3fc7415aa2f8416ef78d8cbb.zip |
Use immutable relation objects to generate queries.
Diffstat (limited to 'activerecord/lib/active_record/calculations.rb')
-rw-r--r-- | activerecord/lib/active_record/calculations.rb | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/calculations.rb b/activerecord/lib/active_record/calculations.rb index cd2fbe9b79..40242333e5 100644 --- a/activerecord/lib/active_record/calculations.rb +++ b/activerecord/lib/active_record/calculations.rb @@ -147,11 +147,11 @@ module ActiveRecord construct_finder_arel_with_included_associations(options, join_dependency) else relation = arel_table(options[:from]). - joins!(construct_join(options[:joins], scope)). - conditions!(construct_conditions(options[:conditions], scope)). - order!(options[:order]). - limit!(options[:limit]). - offset!(options[:offset]) + joins(construct_join(options[:joins], scope)). + conditions(construct_conditions(options[:conditions], scope)). + order(options[:order]). + limit(options[:limit]). + offset(options[:offset]) end if options[:group] return execute_grouped_calculation(operation, column_name, options, relation) @@ -171,7 +171,7 @@ module ActiveRecord (column_name == :all ? "*" : column_name.to_s)) end - relation.select!(operation == 'count' ? column.count(options[:distinct]) : column.send(operation)) + relation = relation.select(operation == 'count' ? column.count(options[:distinct]) : column.send(operation)) type_cast_calculated_value(connection.select_value(relation.to_sql), column_for(column_name), operation) end @@ -194,8 +194,7 @@ module ActiveRecord options[:select] << ", #{group_field} AS #{group_alias}" - relation.select!(options[:select]) - relation.group!(construct_group(options[:group], options[:having], nil)) + relation = relation.select(options[:select]).group(construct_group(options[:group], options[:having], nil)) calculated_data = connection.select_all(relation.to_sql) |