select(sql, name = nil, binds = [], prepare: false, async: false)
private
Show source
def select(sql, name = nil, binds = [], prepare: false, async: false)
if async && async_enabled?
if current_transaction.joinable?
raise AsynchronousQueryInsideTransactionError, "Asynchronous queries are not allowed inside transactions"
end
future_result = async.new(
pool,
sql,
name,
binds,
prepare: prepare,
)
if supports_concurrent_connections? && current_transaction.closed?
future_result.schedule!(ActiveRecord::Base.asynchronous_queries_session)
else
future_result.execute!(self)
end
return future_result
end
result = internal_exec_query(sql, name, binds, prepare: prepare)
if async
FutureResult::Complete.new(result)
else
result
end
end