Method deprecated or moved
This method is deprecated or moved on the latest stable version.
The last existing version (v4.2.9) is shown here.
subquery_for(key, select)
protected
MySQL is too stupid to create a temporary table for use subquery, so we
have to give it some prompting in the form of a subsubquery. Ugh!
Show source
def subquery_for(key, select)
subsubselect = select.clone
subsubselect.projections = [key]
subsubselect.distinct unless select.limit || select.offset || select.orders.any?
subselect = Arel::SelectManager.new(select.engine)
subselect.project Arel.sql(key.name)
subselect.from subsubselect.as('__active_record_temp')
end