Don't give up statement cache just because of there is one `composed_of`

It is too pessimistic, we can check the attribute whether aggregated or
not by `reflect_on_aggregation`.
This commit is contained in:
Ryuta Kamizono 2020-06-05 12:14:15 +09:00
parent dbda5febe4
commit c2dc793e59
1 changed files with 3 additions and 1 deletions

View File

@ -196,7 +196,7 @@ module ActiveRecord
end
def find_by(*args) # :nodoc:
return super if scope_attributes? || reflect_on_all_aggregations.any? ||
return super if scope_attributes? ||
columns_hash.key?(inheritance_column) && !base_class?
hash = args.first
@ -210,6 +210,8 @@ module ActiveRecord
reflection = _reflect_on_association(name)
if reflection&.belongs_to? && !reflection.polymorphic?
reflection.join_foreign_key
elsif reflect_on_aggregation(name)
return super
else
name
end