aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-04-13 12:23:56 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-04-13 12:23:56 -0300
commit0bccde963c0b3e2ad65b2bdac9d144f40854ec90 (patch)
tree9919f64224bf15330c46696b868cb637211f78cd /activerecord/lib/active_record
parentbae857b72174e88d95716e9f551572d51fcfc335 (diff)
parent783982ab2df7a65e97d098ac1ab624436eb7c278 (diff)
downloadrails-0bccde963c0b3e2ad65b2bdac9d144f40854ec90.tar.gz
rails-0bccde963c0b3e2ad65b2bdac9d144f40854ec90.tar.bz2
rails-0bccde963c0b3e2ad65b2bdac9d144f40854ec90.zip
Merge pull request #14592 from laurocaetano/equality_between_relation_and_collection_proxy
The comparison between `Relation` and `CollectionProxy` should be consistent. Conflicts: activerecord/CHANGELOG.md
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/association_relation.rb4
-rw-r--r--activerecord/lib/active_record/relation.rb2
2 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/association_relation.rb b/activerecord/lib/active_record/association_relation.rb
index ef9650d482..45f1b07f69 100644
--- a/activerecord/lib/active_record/association_relation.rb
+++ b/activerecord/lib/active_record/association_relation.rb
@@ -17,6 +17,10 @@ module ActiveRecord
@association.empty?
end
+ def ==(other)
+ other == to_a
+ end
+
private
def exec_queries
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb
index d1764a2bb2..709edbee88 100644
--- a/activerecord/lib/active_record/relation.rb
+++ b/activerecord/lib/active_record/relation.rb
@@ -569,6 +569,8 @@ module ActiveRecord
# Compares two relations for equality.
def ==(other)
case other
+ when Associations::CollectionProxy, AssociationRelation
+ self == other.to_a
when Relation
other.to_sql == to_sql
when Array