diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2017-09-04 03:51:24 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2017-09-04 03:51:24 +0900 |
commit | 925e6d561ae8847777e57f6a0bacc930d35bf05b (patch) | |
tree | 9bcbeb237f9593dd352172dbcc6350ac300851ee /activerecord/lib/active_record/associations/preloader | |
parent | 6a099b168216db45be2d95aa51eac62100b62058 (diff) | |
download | rails-925e6d561ae8847777e57f6a0bacc930d35bf05b.tar.gz rails-925e6d561ae8847777e57f6a0bacc930d35bf05b.tar.bz2 rails-925e6d561ae8847777e57f6a0bacc930d35bf05b.zip |
Scope in associations should treat nil as `all`
Defined scope treats nil as `all`, but scope in associations isn't so.
If the result of the scope is nil, most features on associations will be
broken. It should treat nil as `all` like defined scope.
Fixes #20823.
Diffstat (limited to 'activerecord/lib/active_record/associations/preloader')
-rw-r--r-- | activerecord/lib/active_record/associations/preloader/association.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/preloader/association.rb b/activerecord/lib/active_record/associations/preloader/association.rb index 4915a37f06..3fa97af759 100644 --- a/activerecord/lib/active_record/associations/preloader/association.rb +++ b/activerecord/lib/active_record/associations/preloader/association.rb @@ -113,7 +113,7 @@ module ActiveRecord end def reflection_scope - @reflection_scope ||= reflection.scope_for(klass) + @reflection_scope ||= reflection.scope ? reflection.scope_for(klass.unscoped) : klass.unscoped end def build_scope |