On 16 Jun 2009, at 11:00, Michael Koziarski wrote:
>
>> - Make :include *always* use preload strategy unless the required
>> data set
>> is explicitly loaded
>> - Introduce :left_joins and :right_joins keys to the finder. Title
>> says it
>> all
>> - Make user explicitly specify the required joins if they want to put
>> conditions on the associations
>> - For all the associations specified in :include, check if the
>> required
>> dataset has already been loaded by :*joins. If not, preload.
>> Thoughts ?
>
> Sounds good to me, but I also like the idea of being able to do
> something like
>
> @orders = Order.find_by_sql(CRAZY_SHIT)
> @orders.preload(:line_items=>{:sku=>:title})
I'd love that too (and the result set proxy I fiddled with did get you
that. Don't know if it still works with current versions of rails).
Also handy when the bit fetching your orders has no idea that you're
going to be displaying the orders along with various associations
(although often scopes and what not can mitigate that).
There is one particular case where preload is broken for :include,
when you have a hmt with conditions on the join model (I've been
meaning to do this for a little while but not gotten around to it.
Last time I thought about it it needed a slight refactor of HMT so
that preload doesn't have to duplicate the code that generates the
join statements you need)
Fred
>
> --
> Cheers
>
> Koz
>
> >
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---