mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
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:
parent
dbda5febe4
commit
c2dc793e59
1 changed files with 3 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue