I just got bit by a pretty subtle bug with eager loading.  Basically
what happened is mixing a :group and :include clause.  The group
clause of course collapsed the associations so I only got one of each
association (this was not immediately obvious due to the data I'm
working with).  What makes it so subtle is that if the Preload
strategy is used then there is no problem.

In my case the condition it was even less obvious because the
condition that was triggering the Join strategy was not applicable
anyway.  I realize that parsing the conditions and cross-referencing
to other options in order to determine the true applicability of the
Join is a rabbit hole no one wants to go down.

But I was thinking about the other side.  If there is a :group clause
in a query, my gut instinct is that a large majority of the time it is
going to clobber associations.  Given the fact that it is pretty easy
to add explicit joins to satisfy conditions, but pretty ugly to force
the preload strategy, would there be any support for either:

A) setting up :group clause to force the Preload strategy

B) raising an exception or warning if :group is used with :include of
a non-singular association

C) giving access to the Preload strategy explicitly

I'm finding a proliferation of Klass.send(:preload_associations,
foo, :bar) throughout my codebase and it doesn't smell good.  The more
I think about, the more C seems like it might be the only reasonable
option.  Thoughts?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to