diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-02-27 10:57:40 -0800 |
---|---|---|
committer | George Brocklehurst <george.brocklehurst@gmail.com> | 2012-11-10 13:32:11 +0100 |
commit | a3cf03ef99b2cfd811e0ca5cd31ef57976a9408b (patch) | |
tree | 6dbf53fb64047463dcc4983f875f4242377a33eb /activerecord/lib/active_record/relation/calculations.rb | |
parent | 5f508471b8919ec8d5fc3b6cbe24978a36de8150 (diff) | |
download | rails-a3cf03ef99b2cfd811e0ca5cd31ef57976a9408b.tar.gz rails-a3cf03ef99b2cfd811e0ca5cd31ef57976a9408b.tar.bz2 rails-a3cf03ef99b2cfd811e0ca5cd31ef57976a9408b.zip |
use bind values for join columns
This is a backport of 4bc2ae0da1dd812aee759f6d13ad428354cd0e13.
It fixes bug #7950.
Conflicts:
activerecord/lib/active_record/relation/calculations.rb
activerecord/lib/active_record/relation/finder_methods.rb
Diffstat (limited to 'activerecord/lib/active_record/relation/calculations.rb')
-rw-r--r-- | activerecord/lib/active_record/relation/calculations.rb | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb index 802059db21..8270292c43 100644 --- a/activerecord/lib/active_record/relation/calculations.rb +++ b/activerecord/lib/active_record/relation/calculations.rb @@ -178,7 +178,7 @@ module ActiveRecord # def pluck(column_name) column_name = column_name.to_s - klass.connection.select_all(select(column_name).arel).map! do |attributes| + klass.connection.select_all(select(column_name).arel, nil, bind_values).map! do |attributes| klass.type_cast_attribute(attributes.keys.first, klass.initialize_attributes(attributes)) end end @@ -240,7 +240,8 @@ module ActiveRecord query_builder = relation.arel end - type_cast_calculated_value(@klass.connection.select_value(query_builder), column_for(column_name), operation) + result = @klass.connection.select_value(query_builder, nil, relation.bind_values) + type_cast_calculated_value(result, column_for(column_name), operation) end def execute_grouped_calculation(operation, column_name, distinct) #:nodoc: @@ -286,7 +287,7 @@ module ActiveRecord relation = except(:group).group(group) relation.select_values = select_values - calculated_data = @klass.connection.select_all(relation) + calculated_data = @klass.connection.select_all(relation, nil, bind_values) if association key_ids = calculated_data.collect { |row| row[group_aliases.first] } |