On Saturday 12 July 2008 20:57:01 Kyle Schaffrick wrote:
> I can't figure out any good way to phrase my question without some
> pipe-laying, so here I go...
>
> I have a pattern of doing some various query activities in my app
> that ultimately result in retrieving a single instance of one of my
> mapped classes from the ORM. So naturally I stuck that pattern in a
> function, which I pass my session object, a class, and some other
> parameters and it either hands me an instance or raises exceptions.
> The point here is that I never see a Query object if I use this
> function.
>
> So, now suppose I have my instance (call it "obj") and it has a 1-M
> relation, obj.rel, to a class Secondary. Secondary is in turn
> related (1-1 in this case) to Tertiary.
>
> If I start iterating over the obj.rel collection and access the
> Tertiary objects, I get O(n) behavior as one would expect. Is it
> possible to set up an eager-load of the Tertiary relation from
> *here*, 

> after the Query is long gone? 
if it is really gone/done, who should eager-load?
u can setup eagerload'ing per query (or per declaration of relation, 
but that's too general) - query.options( ) - eagerload( prop) or 
contains_eager( prop), i'm not sure about the difference. but all 
this before the query is executed..
but if u're asking about can u request eagerload(a.b.c.d), yes u can, 
it is eagerload_all(), see the docs.

> I would love to avoid  
> tangling "should I eager-load or not" logic into the
> instance-fetching function, just for these one or two cases.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" 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/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to