Closed alexmobo closed 6 years ago
👍
👍
Technically speaking, that SQL is not making a temporary table - it is a subquery. As such, I would recommend re-naming the class to Arel::Subquery
and reserve Arel::TemporaryTable
for true temporary tables to avoid confusion.
Further, theres more than one way to create temporary tables (depending on db provider). Examples:
SELECT id INTO TEMPORARY TABLE tmp_ids FROM foos
CREATE TEMPORARY TABLE tmp_ids AS SELECT id FROM foos
Currently, I'm currently having trouble using AREL to create such a temporary table with AREL when common table expressions (CTE) have been applied.
I have changed TemporaryTable
to Subquery
as @bdevel commented.
Per #523, Arel development is moving to rails/rails.
If this PR is still relevant, please consider reopening it over there.
With this we could do something like
or
to do something like
to produce the sql next output
also if we write something like
without the
as
keyword argument, we get the same as before but with a 10-length random name for the table (i.e.)