Hello; I have recently started on a project using SQLAlchemy, and have run into a problem when trying to join a row in one table to two separate rows in another.
I am working on an application in which users can send messages to each other. I have two tables, a User table, and a Item table. They look as follows: tm_user = Table("user", engine, Column('userid', String(5), primary_key=True, ... ) tm_item = Table("item", engine, Column("itemid", String(5), primary_key=True), ... Column('from_uid', String(5), ForeignKey("user.userid")), Column('to_uid', String(5), ForeignKey("user.userid")) ) Each Item is associated with two Users: the sender ('from_uid') and the recipient ('to_uid'). I have set up mappers like this: map_item = mapper(Item, tm_item) map_user = mapper(User, tm_user, properties = { 'outbox' : relation(mapper(Item,primaryjoin=tm_user.c.userid==Item.c.from_uid)), 'inbox' : relation(mapper(Item, primaryjoin=tm_user.c.userid==Item.c.to_uid)), } ) The problem with this is that, when I create a User object with a query and inspect its inbox and outbox properties, I find that each one contains only Items where both from_uid and to_uid are equal to userid. How can I change this so that outbox only matches by from_uid and inbox by to_uid? Thanks, Andrew Bulhak ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 _______________________________________________ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users