rails/rails — pull request #6058 by RStankov (2012-04-29 18:27:22+00:00)
Title: Relation#from to accept other Relation objects

Recently several times I have used a subqueries in my project. In genera this pattern I use:

Record.from("(#{sub_query.to_sql})")
Record.from("(#{sub_query.to_sql}) a")

And I was wondering if it will be good to have this build into ActiveRecord so we can do:

Record.from("(#{sub_query.to_sql})") -> Record.from(sub_query)
Record.from("(#{sub_query.to_sql}) a") -> Record.from(:a => sub_query)