On Sun, 13 Jul 2008 00:18:35 -0400
Kyle Schaffrick <[EMAIL PROTECTED]> wrote:
> > To setup the eagerness of "cs" at the exact point of lazy load,
> > the public API that allows this is via "lazy='dynamic'", which would
> > allow:
> >
> > a = sess.query(A).first()
> > print a.bs.option(eagerload('cs')).first()
> >
> > But that changes the "lazyness" of "bs" considerably.
>
> This seems like it might be pointing to a solution, but, what do you
> mean by the last statement?
Er, I think I misread you the first time, this looks like it would
involve modifying the mapper, to turn "bs" into a Query factory.
Wouldn't that would break all the rest of the code that treats "bs" like
a collection? Also, would sess.query(A).option(eagerload('bs')) still
work?
Basically what would be ideal in my situation, is if the instrumented
attributes for relations had some method for providing a loading hint,
for ex:
a = ses.query(A).first()
# ...sometime later, in another part of the code, I know I'll be
# iterating over "a.bs" and touching "cs" on each one, so I do:
instance_option(a, eagerload('cs'))
[ c.blah for c in a.bs ] # load of bs eagerloads cs
As I mentioned, in my situation, the query at the top has no knowledge
of what class A is, nor whether or not it needs loading options.
Hoping this is a little more clear...
-Kyle
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---