1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Inlining locked?

Since `locked?` and `arel_from_relation` overlaps, so just do
`arel_from_relation` first and inline `locked?`.
This commit is contained in:
Ryuta Kamizono 2021-01-12 18:14:08 +09:00
parent 0aa832e590
commit b453bff351

View file

@ -94,8 +94,11 @@ module ActiveRecord
end
def select_all(arel, name = nil, binds = [], preparable: nil)
if @query_cache_enabled && !locked?(arel)
arel = arel_from_relation(arel)
arel = arel_from_relation(arel)
# If arel is locked this is a SELECT ... FOR UPDATE or somesuch.
# Such queries should not be cached.
if @query_cache_enabled && !(arel.respond_to?(:locked) && arel.locked)
sql, binds, preparable = to_sql_and_binds(arel, binds, preparable)
cache_sql(sql, name, binds) { super(sql, name, binds, preparable: preparable) }
@ -134,13 +137,6 @@ module ActiveRecord
}
end
# If arel is locked this is a SELECT ... FOR UPDATE or somesuch. Such
# queries should not be cached.
def locked?(arel)
arel = arel.arel if arel.is_a?(Relation)
arel.respond_to?(:locked) && arel.locked
end
def configure_query_cache!
enable_query_cache! if pool.query_cache_enabled
end