diff options
author | Yves Senn <yves.senn@gmail.com> | 2013-02-11 21:24:11 +0100 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2013-02-19 11:11:27 +0100 |
commit | 587f563c40cfada296d6e8d6bbe3c4d7fc6ce93b (patch) | |
tree | f73e5e490d1e5de640f83797a2b19325e2f82fb5 /activerecord/lib/active_record/associations/preloader | |
parent | 46b65ba274bea6f8d52926e4b243db28d6377fc0 (diff) | |
download | rails-587f563c40cfada296d6e8d6bbe3c4d7fc6ce93b.tar.gz rails-587f563c40cfada296d6e8d6bbe3c4d7fc6ce93b.tar.bz2 rails-587f563c40cfada296d6e8d6bbe3c4d7fc6ce93b.zip |
don't cache invalid subsets when preloading hmt associations.
Backport #9252.
Conflicts:
activerecord/CHANGELOG.md
activerecord/test/cases/associations/eager_test.rb
The preloader code on 3-2-stable is not based on relations but on option hashes.
I had to modify the original patch and comparing the option hashes could be more
fuzzy than comparing the relations. All the tests passed though.
Diffstat (limited to 'activerecord/lib/active_record/associations/preloader')
-rw-r--r-- | activerecord/lib/active_record/associations/preloader/through_association.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/preloader/through_association.rb b/activerecord/lib/active_record/associations/preloader/through_association.rb index ad6374d09a..4cb7b56b57 100644 --- a/activerecord/lib/active_record/associations/preloader/through_association.rb +++ b/activerecord/lib/active_record/associations/preloader/through_association.rb @@ -37,7 +37,8 @@ module ActiveRecord through_records = Array.wrap(owner.send(through_reflection.name)) # Dont cache the association - we would only be caching a subset - if reflection.options[:source_type] && through_reflection.collection? + if (preload_options != through_options) || + (reflection.options[:source_type] && through_reflection.collection?) owner.association(through_reflection.name).reset end |