Re: [sqlalchemy] Self-Referential Many-to-Many Relationship: related nodes

2012-08-21 Thread adolfo
Thanks. The subquery approach works fine. My class is named 'Caso' (Case, in english) I included at the mapper: subq2=aliased(subq1) CasoMapper = mapper(Caso, caso, properties= { 'LinkedNodes':relation(Caso, secondary=subq2,

[sqlalchemy] Self-Referential Many-to-Many Relationship: related nodes

2012-08-20 Thread adolfo
I have a Self-Referential Many-to-Many Relationship situation where the right_nodes = relationship(Node, secondary=node_to_node, primaryjoin=id==node_to_node.c.left_node_id, secondaryjoin=id==node_to_node.c.right_node_id,

Re: [sqlalchemy] Self-Referential Many-to-Many Relationship: related nodes

2012-08-20 Thread Michael Bayer
On Aug 20, 2012, at 6:07 PM, adolfo wrote: I have a Self-Referential Many-to-Many Relationship situation where the right_nodes = relationship(Node, secondary=node_to_node, primaryjoin=id==node_to_node.c.left_node_id,

Re: [sqlalchemy] Self-Referential Many-to-Many Relationship: related nodes

2012-08-20 Thread adolfo
Thanks Michael. The question is: how can I use that trick as a relation? I can do: session.query(Node).outerjoin(Node.right_nodes) and session.query(Node).outerjoin(Node.left_nodes) but not session.query(Node).outerjoin(Node.all_nodes) and that is what I'm looking for. I mean the

Re: [sqlalchemy] Self-Referential Many-to-Many Relationship: related nodes

2012-08-20 Thread Michael Bayer
On Aug 20, 2012, at 7:08 PM, adolfo wrote: Thanks Michael. The question is: how can I use that trick as a relation? I can do: session.query(Node).outerjoin(Node.right_nodes) and session.query(Node).outerjoin(Node.left_nodes) but not