On Nov 19, 2013, at 7:11 PM, askel <dummy...@mail.ru> wrote: > Hello everybody, > > I have a question I couldn't find answer on my own so I'll greatly appreciate > if someone could give me an answer. > > Considering simple model https://gist.github.com/momyc/7554839, why would > query like the following work: > > session.query(SourceA).join(SourceA.trans).filter(Trans.amount>0) > > while the following one fails to build join expression: > > session.query(SourceA).join(Trans).filter(Trans.amount>0) > > I suspect that this is because there is not ForeignKey in class/mapper/table > declaration. Or, perhaps, I missed something in building that relationship. > > It's not a show stopper and I can definitely live with that but knowing why > would bring harmony back to this world :)
that would be correct, when you say query(A).join(B), the relationship() construct isn’t used to resolve how to join those, only the ForeignKey that exists between the two tables (if any). I suppose that’s something else that might be improved upon someday though I’m sort of tapped on adding behavioral changes to 0.9….
signature.asc
Description: Message signed with OpenPGP using GPGMail