On Aug 10, 2010, at 10:13 AM, Michael Brickenstein wrote: > Hi! > > SQLAlchemy is really awesome (I really love it) > and I am still working on the RUM web frontend for it. > > I have the problem, that I would like to make some nested join: > > query=session.query(Address) > query=query.join(User, Address.user) > query=query.join(Group, User.group) > > Is it legal to the join this way?
its legal but not what you're intending. your intention is: query=session.query(Address) query=query.join((User, Address.user)) query=query.join((Group, User.group)) but you really only need: query=session.query(Address) query=query.join(Address.user) query=query.join(User.group) we've recently added checking to detect a common error of query.join(User, User.id==Address.user_id), but yours above is a less common variant of that. > > The clauses seem to be duplicated: > > SELECT addresses.id AS addresses_id, addresses.email_address AS > addresses_email_address, addresses.user_id AS addresses_user_id > FROM addresses > JOIN users ON users.id = addresses.user_id > JOIN users ON users.id = addresses.user_id > JOIN groups ON groups.id = users.group_id > JOIN groups ON groups.id = users.group_id > > I attach a full example to this mail. > I got the same behaviour with all versions I tried (0.5.8 (the example is for > 0.6.x), 0.6.1, and 0.6.3. > > Thank you very much in advance. > Michael > > > ------------------------------------------- > Michael Brickenstein > Mathematisches Forschungsinstitut Oberwolfach gGmbH > Schwarzwaldstr. 9 - 11 > 77709 Oberwolfach > Tel.: 07834/979-31 > Fax: 07834/979-38 > > <doublejoin.py>-- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To post to this group, send email to sqlalch...@googlegroups.com. > To unsubscribe from this group, send email to > sqlalchemy+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/sqlalchemy?hl=en. > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.