aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2013-06-19 14:22:02 +0100
committerJon Leighton <j@jonathanleighton.com>2013-06-19 14:22:02 +0100
commite47b6dee858e62dceba867dd160b968d679c82e8 (patch)
treec4c2226023f852026efbf744b1447a4133769e18
parentb6a711f5f44d86554001ddd2ce52f19039073bd2 (diff)
downloadrails-e47b6dee858e62dceba867dd160b968d679c82e8.tar.gz
rails-e47b6dee858e62dceba867dd160b968d679c82e8.tar.bz2
rails-e47b6dee858e62dceba867dd160b968d679c82e8.zip
Revert "Merge pull request #10566 from neerajdotname/10509d"
This reverts commit 2b817a5e89ac0e7aeb894a40ae7151a0cf3cef16, reversing changes made to 353a398bee68c5ea99d76ac7601de0a5fef6f4a5. Conflicts: activerecord/CHANGELOG.md Reason: the build broke
-rw-r--r--activerecord/CHANGELOG.md16
-rw-r--r--activerecord/lib/active_record/associations/collection_association.rb2
-rw-r--r--activerecord/test/cases/associations/inverse_associations_test.rb8
3 files changed, 1 insertions, 25 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index 933ac9fa6c..87167d0529 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -9,22 +9,6 @@
*Neeraj Singh*
-* Do not load all child records for inverse case.
-
- currently `post.comments.find(Comment.first.id)` would load all
- comments for the given post to set the inverse association.
-
- This has a huge performance penalty. Because if post has 100k
- records and all these 100k records would be loaded in memory
- even though the comment id was supplied.
-
- Fix is to use in-memory records only if loaded? is true. Otherwise
- load the records using full sql.
-
- Fixes #10509.
-
- *Neeraj Singh*
-
* Fixture setup does no longer depend on `ActiveRecord::Base.configurations`.
This is relevant when `ENV["DATABASE_URL"]` is used in place of a `database.yml`.
diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb
index 9833822f8f..efd7ecb97c 100644
--- a/activerecord/lib/active_record/associations/collection_association.rb
+++ b/activerecord/lib/active_record/associations/collection_association.rb
@@ -81,7 +81,7 @@ module ActiveRecord
else
if options[:finder_sql]
find_by_scan(*args)
- elsif options[:inverse_of] && loaded?
+ elsif options[:inverse_of]
args = args.flatten
raise RecordNotFound, "Couldn't find #{scope.klass.name} without an ID" if args.blank?
diff --git a/activerecord/test/cases/associations/inverse_associations_test.rb b/activerecord/test/cases/associations/inverse_associations_test.rb
index 993e7294cf..b1f0be3204 100644
--- a/activerecord/test/cases/associations/inverse_associations_test.rb
+++ b/activerecord/test/cases/associations/inverse_associations_test.rb
@@ -401,14 +401,6 @@ class InverseHasManyTests < ActiveRecord::TestCase
assert_equal man.name, man.interests.find(interest.id).man.name, "The name of the man should match after the child name is changed"
end
- def test_find_on_child_instance_with_id_should_not_load_all_child_records
- man = Man.create!
- interest = Interest.create!(man: man)
-
- man.interests.find(interest.id)
- refute man.interests.loaded?
- end
-
def test_raise_record_not_found_error_when_invalid_ids_are_passed
man = Man.create!