I've thought about that in the abstract and it makes a lot of sense.
Another way to add power and flexibility would be public hooks to the
eager loaded table name aliases (maybe this can be done already, it's
just not documented).

However I think the base case that I'm talking about should definitely
be fixed.  It's not some crazy edge case.  It's just maintaining the
order of the association.  The solution is quite simple: DON'T include
the order clause on the ID-fetching query for limited eager loading,
but DO include it (by appending) on the actual query.

My entire app is built around search, and I'm leveraging pretty much
all the features of ActiveRecord, so using find_by_sql just isn't
practical.  If I were to do so, I would have to write code duplicating
75% of ActiveRecord functionality just to build my queries.  Kind of
like writing an SQL parser is a bad thing for ActiveRecord to do,
writing a query generator that can process :include, :conditions,
:limit, :offset, etc would be a bad thing for my app to do.

On 6/30/07, Michael Koziarski <[EMAIL PROTECTED]> wrote:
>
> > Often times it's a performance
> > necessity, and it's one area where falling back to find_by_sql just
> > doesn't work because you can't easily construct the association
> > targets from a raw sql query.
>
> Building a SQL parser immediately sets off all sorts of alarm bells.
> However perhaps the proper solution is to simply remedy this problem
> If you can do fancy find_by_sql and get the snippet of your object
> graph back, then it makes it less important to start guessing intent
> of our users.
>
> The apps I'm working on don't typically need to use complicated
> queries to return a chunk of the object graph.  Most of the
> hand-written sql I use gets fed into aggregate queries of some kind.
>
> If you're currently hitting the limits of the current system, perhaps
> that's the motivation needed to investigate improving find_by_sql?
>
> --
> Cheers
>
> Koz
>
> >
>


-- 
Gabe da Silveira
http://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