From d333d85254d27cd572e6ecce8ee850c107a4f340 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Wed, 27 Feb 2019 02:31:39 +0900 Subject: 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. --- activerecord/lib/active_record/core.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'activerecord/lib/active_record/core.rb') 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 -- cgit v1.2.3