diff --git a/activerecord/lib/active_record/relation/from_clause.rb b/activerecord/lib/active_record/relation/from_clause.rb index 93b129ce99000ded6434cc82a111621c961d181b..d1520f77aa6421351935015ff8074d4f8752a5a0 100644 --- a/activerecord/lib/active_record/relation/from_clause.rb +++ b/activerecord/lib/active_record/relation/from_clause.rb @@ -18,6 +18,10 @@ def empty? value.nil? end + def ==(other) + other.is_a?(FromClause) && name == other.name && value == other.value + end + def self.empty @empty ||= new(nil, nil).freeze end diff --git a/activerecord/test/cases/relation/or_test.rb b/activerecord/test/cases/relation/or_test.rb index e650da3a32dd89705541d05ff839fd70807bc2ab..95375eb4eeba54574080c534868ef2f19919db9e 100644 --- a/activerecord/test/cases/relation/or_test.rb +++ b/activerecord/test/cases/relation/or_test.rb @@ -147,6 +147,7 @@ def test_structurally_incompatible_values Post.group(:author_id).group(:author_id).or(Post.group(:author_id)) Post.joins(:author).joins(:author).or(Post.joins(:author)) Post.left_outer_joins(:author).left_outer_joins(:author).or(Post.left_outer_joins(:author)) + Post.from("posts").or(Post.from("posts")) end end end