It certainly works decently with `from`. Can that be leveraged somehow? I 
am just taking a wild guess here. I haven't really read the code very 
thoroughly to determine feasibility.

On Monday, December 14, 2015 at 8:46:31 AM UTC-7, Prem Sichanugrist wrote:
>
> I have seen that use case before. I'm not sure how we could make the API 
> to be user-friendly enough for a subquery though. I think your current 
> implementation is good enough while still able to use ARel.
>
> -Prem
>
> On Dec 14, 2015, at 10:25 AM, Francisco Soto <[email protected] 
> <javascript:>> wrote:
>
> In certain type of queries (filtering, reporting, etc) it is common have a 
> subquery to select from, currently supported with from, and to join into 
> subqueries (inline views) which is not supported.
>
> I just ran into said situation which I had to solve by doing the subquery 
> as a relationship and calling to_sql and then using the string form of 
> joins.
>
> Like:
>
>    subquery = SomeTable
>                 .scope
>                 .scope
>                 .group(:whatever)
>                 .having("something")
>                 .to_sql
>
>    OtherTable.joins("INNER JOIN (#{subquery}) PT ON PT.ID = 
> other_tables.id")
>
> Would it be possible to implement (or take a PR?) support for this case?
>
> Best regards,
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Core" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] <javascript:>.
> To post to this group, send email to [email protected] 
> <javascript:>.
> Visit this group at https://groups.google.com/group/rubyonrails-core.
> For more options, visit https://groups.google.com/d/optout.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to