aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation
diff options
context:
space:
mode:
author90yukke <yukke.90@gmail.com>2013-07-22 23:08:02 +0300
committer90yukke <yukke.90@gmail.com>2013-07-23 10:38:00 +0300
commitb289519f4ff7829271674d66d3196e1ee23056b6 (patch)
tree7fdbeebaac918d4cef96f2b294697e2c2cf850db /activerecord/lib/active_record/relation
parente0db277be0a57386d299fc0a231b585a612eb9ba (diff)
downloadrails-b289519f4ff7829271674d66d3196e1ee23056b6.tar.gz
rails-b289519f4ff7829271674d66d3196e1ee23056b6.tar.bz2
rails-b289519f4ff7829271674d66d3196e1ee23056b6.zip
Fix merge error when Equality LHS is non-attribute.
This is reworking of rails/rails/pull/7380 made for rails 3.
Diffstat (limited to 'activerecord/lib/active_record/relation')
-rw-r--r--activerecord/lib/active_record/relation/spawn_methods.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/relation/spawn_methods.rb b/activerecord/lib/active_record/relation/spawn_methods.rb
index 90f2ac3cde..b734fc5c51 100644
--- a/activerecord/lib/active_record/relation/spawn_methods.rb
+++ b/activerecord/lib/active_record/relation/spawn_methods.rb
@@ -32,11 +32,12 @@ module ActiveRecord
merged_wheres = @where_values + r.where_values
unless @where_values.empty?
- # Remove duplicates, last one wins.
+ # Remove duplicate ARel attributes. Last one wins.
seen = Hash.new { |h,table| h[table] = {} }
merged_wheres = merged_wheres.reverse.reject { |w|
nuke = false
- if w.respond_to?(:operator) && w.operator == :==
+ if w.respond_to?(:operator) && w.operator == :== &&
+ w.left.respond_to?(:relation)
name = w.left.name
table = w.left.relation.name
nuke = seen[table][name]