As it turns out, extending the order clause doesn't even work for
eager loading with a limit clause since the initial query to find the
IDs doesn't include the joined table, and therefore the clause blows
up.  ActiveRecord will need to parse the order string to prevent this
condition...  As it is, I'll have to either not eager load the
association (n+1 ugh), or else sort the association after it is loaded
(not bad for small associations, but not very DRY).

Does AR do any analysis of ORDER clauses currently?

On Jun 29, 1:43 pm, "Gabe da Silveira" <[EMAIL PROTECTED]> wrote:
> I'm using eager loading pretty heavily and running up into a lot of
> edge cases that I'd like to work on.  The latest is that :order
> clauses on associations appear to be dropped when the association is
> eager loaded.  This makes sense since you generally would want to
> specify the order on your query, and it's prone to name collisions.
> However the downside is that I'm doing a LOT of eager loading and it's
> pretty ugly to be extending every single order clause through the
> application with association orders (considering the associations will
> always be ordered the same).  Throw in the fact that my :include
> option is sometimes specified dynamically (for API use and such), and
> constructing the proper order clause turns into a very significant
> undertaking.
>
> I'm wondering if any ActiveRecord experts in here can comment on the
> feasibility of factoring :order options into eager-loaded associations
> intelligently.  Ideally it would always use the associations order
> clause unless the passed-in order clause contained a reference to the
> eager-loaded table.  Given the table renaming and the possibility of
> explicit joins, this could be complicated, but I think it could be
> made to work reasonably well.  Any comments before I start work on a
> patch?
>
> --
> Gabe da Silveirahttp://darwinweb.net


--~--~---------~--~----~------------~-------~--~----~
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