diff options
author | Benedikt Deicke <benedikt@synatic.net> | 2012-04-03 16:51:36 +0200 |
---|---|---|
committer | Benedikt Deicke <benedikt@synatic.net> | 2012-04-03 17:00:37 +0200 |
commit | 68677ffb8298105eb9d3efa26d928dd88cc5e006 (patch) | |
tree | fe4a803a12f512fc12f3b890d5c0fa275eb924cb /activerecord/test | |
parent | 0cc6c5fec235cca6d7eb85d4f849536db8566e93 (diff) | |
download | rails-68677ffb8298105eb9d3efa26d928dd88cc5e006.tar.gz rails-68677ffb8298105eb9d3efa26d928dd88cc5e006.tar.bz2 rails-68677ffb8298105eb9d3efa26d928dd88cc5e006.zip |
Removes caching from ActiveRecord::Core::ClassMethods#relation
The #relation method gets called in four places and the return value was instantly cloned in three of them. The only place that did not clone was ActiveRecord::Scoping::Default::ClassMethods#unscoped. This introduced a bug described in #5667 and should really clone the relation, too. This means all four places would clone the relation, so it doesn't make a lot of sense caching it in the first place.
The four places with calls to relations are:
activerecord/lib/active_record/scoping/default.rb:110:in `block in build_default_scope'"
activerecord/lib/active_record/scoping/default.rb:42:in `unscoped'"
activerecord/lib/active_record/scoping/named.rb:38:in `scoped'"
activerecord/lib/active_record/scoping/named.rb:52:in `scope_attributes'"
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/relations_test.rb | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index 25eb7c1672..af25db05cf 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -1099,6 +1099,10 @@ class RelationTest < ActiveRecord::TestCase assert_equal 'honda', FastCar.unscoped { FastCar.order_using_old_style.limit(1).first.name} end + def test_unscoped_relation_clones + assert_not_equal CoolCar.unscoped.object_id, CoolCar.unscoped.object_id + end + def test_intersection_with_array relation = Author.where(:name => "David") rails_author = relation.first |