On Tue, Jun 16, 2009 at 11:53 PM, Will Bryant <[email protected]> wrote:
> I like this approach. :include should definitely preload, and people
> should have to use :joins and :left_joins when they need them all in the
> same query.
> What would :right_joins do though? You need a left record to load
> associations of, otherwise how would you get to the right objects?
>
Right join is just one of the gazzilion JOINs a typical RDBMS supports. But
I guess we could live without it.
>
> Regarding making people explicitly specify the required joins to put
> conditions on the associations, if I understand you correctly, I think this
> would tend to mean that you end up with numerous copies of your basic
> foreign key-based join conditions throughout the codebase, which is not very
> DRY.
>
Not really. You can already specify associations in :joins arguments. So
your example would be :
Lunch.find(:all, :left_joins => :pies, :conditions => {:pies => {:steak =>
true}})
Or if you also want to instantiate pies :
Lunch.find(:all, :left_joins => :pies, :conditions => {:pies => {:steak =>
true}}, :include => :pies)
In this specific case, you could just use :joins too - which uses INNER
JOIN.
As for your scope example, I think that's a different problem altogether.
Thanks!
<snip />
--
Cheers!
- Pratik
http://m.onkey.org
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---