diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2019-02-27 02:31:39 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2019-02-27 03:40:53 +0900 |
commit | d333d85254d27cd572e6ecce8ee850c107a4f340 (patch) | |
tree | ee09f2979268cc1f3831ce83ef7d366418157750 /activerecord/lib | |
parent | b78e3b5e21b9924324c4391cc58afac8c7b4cccb (diff) | |
download | rails-d333d85254d27cd572e6ecce8ee850c107a4f340.tar.gz rails-d333d85254d27cd572e6ecce8ee850c107a4f340.tar.bz2 rails-d333d85254d27cd572e6ecce8ee850c107a4f340.zip |
Don't cache `find_by` statements on STI subclasses
Caching `find_by` statements on STI subclasses is unsafe, since
`type IN (?,?,?,?)` part is dynamic, and we don't have SQL statements
cache invalidation when a STI subclass is created or removed for now.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/core.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb index c67980173f..18cfac1f2f 100644 --- a/activerecord/lib/active_record/core.rb +++ b/activerecord/lib/active_record/core.rb @@ -182,7 +182,8 @@ module ActiveRecord end def find_by(*args) # :nodoc: - return super if scope_attributes? || reflect_on_all_aggregations.any? + return super if scope_attributes? || reflect_on_all_aggregations.any? || + columns_hash.key?(inheritance_column) && !base_class? hash = args.first |