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/spawn_methods.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/spawn_methods.rb')
-rw-r--r-- | activerecord/lib/active_record/relation/spawn_methods.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/spawn_methods.rb b/activerecord/lib/active_record/relation/spawn_methods.rb index c25570d758..3eead56e47 100644 --- a/activerecord/lib/active_record/relation/spawn_methods.rb +++ b/activerecord/lib/active_record/relation/spawn_methods.rb @@ -22,7 +22,7 @@ module ActiveRecord end end - (Relation::MULTI_VALUE_METHODS - [:joins, :where, :order]).each do |method| + (Relation::MULTI_VALUE_METHODS - [:joins, :where, :order, :binds]).each do |method| value = r.send(:"#{method}_values") merged_relation.send(:"#{method}_values=", merged_relation.send(:"#{method}_values") + value) if value.present? end @@ -31,6 +31,8 @@ module ActiveRecord merged_wheres = @where_values + r.where_values + merged_binds = (@bind_values + r.bind_values).uniq(&:first) + unless @where_values.empty? # Remove duplicates, last one wins. seen = Hash.new { |h,table| h[table] = {} } @@ -47,6 +49,7 @@ module ActiveRecord end merged_relation.where_values = merged_wheres + merged_relation.bind_values = merged_binds (Relation::SINGLE_VALUE_METHODS - [:lock, :create_with, :reordering]).each do |method| value = r.send(:"#{method}_value") |