Ah!

Cool, that makes sense.
Changed the code to:
 # query = db.query(User).options(subqueryload(User.web_login),
subqueryload(User.facebook_connect))

Upgraded to 0.7.5. And that did the trick, now both tables are loaded
as subqueries.

Thank you Michael!
Much appreciated!
/JT


On Feb 13, 4:44 pm, Michael Bayer <[email protected]> wrote:
> On Feb 13, 2012, at 10:18 AM, Jevgenij wrote:
>
>
>
>
>
>
>
>
>
> > Hi SQLAlchemy users,
>
> > We are using SQLAlchemy for our new web app, and ran into a problem,
> > still learning and are unsure if we found a bug or we are just using
> > the framework wrong.
>
> > We have a table called "user" and two child tables:
> > ------
> > class FacebookConnect(Base):
> >    __tablename__ = 'facebook_connects'
> >    ...
> >    user = relationship(User, backref=backref('facebook_connect',
> > uselist=False))
>
> > class WebLogin(Base):
> >    __tablename__ = 'web_logins'
> >    ...
> >    user = relationship(User, backref=backref('web_login',
> > uselist=False))
> > -----
>
> > user and the other two tables have a 1..1 <---> 0..1 relationship.
>
> > In our admin we load a list of users like this:
> > users = db.query(User).options(subqueryload(User.web_login,
> > User.facebook_connect))
>
> The bug was actually fixed in 0.7.5 which is that it was silently failing to 
> report that this is the wrong usage.  You want to use two "subqueryload()" 
> directives here, one for User.web_login, one for User.facebook_connect.
>
> The XYZload() directives only handle one path through the model each; the 
> multiple entries is so you could say subqueryload(User.web_login, 
> WebLogin.widgets) which would cause "WebLogin.widgets" to be subqueryloaded 
> as soon as User.web_login were lazy loaded, or 
> subqueryload_all(User.web_login, WebLogin.widgets) to load both.   But in 
> both cases its one path.

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