As I said in my previous mail, you really should look at the "remote_side" keyword argument in your relation. This is what it was done for and the paragraph "adjacency-list-relationships" from the documentation covers all you need to know to deal with self-referential relationships.
Here's the link again: http://www.sqlalchemy.org/docs/05/mappers.html#adjacency-list-relationships Regards, Alex 2009/2/16 一首诗 <newpt...@gmail.com>: > > Like this ? > ------------------------------------------------------------------------------------------------ > class User(Base): > __tablename__ = 'users' > > id = Column(Integer, primary_key=True) > name = Column(String) > fullname = Column(String) > password = Column(String) > sons = relation('User', order_by='User.id', backref="parent") > > ------------------------------------------------------------------------------------------------ > > I got an Exception: > > sqlalchemy.exc.ArgumentError: Could not determine join condition > between parent/child tables on relation User.sons. Specify a > 'primaryjoin' expression. If this is a many-to-many relation, > 'secondaryjoin' is needed as well. > > > On Feb 16, 5:08 pm, a...@svilendobrev.com wrote: >> put it as text, it will be eval()'uated later >> >> On Monday 16 February 2009 10:57:11 一首诗 wrote: >> >> > I tried to write : >> >> > #------------------------------------------------------------------ >> >------------------ class User(Base): >> > __tablename__ = 'users' >> >> > id = Column(Integer, primary_key=True) >> > name = Column(String) >> > fullname = Column(String) >> > password = Column(String) >> > sons = relation(User, order_by=User.id, backref="parent") >> > #------------------------------------------------------------------ >> >------------------ >> >> > But the as 'User' is not defined at the line "... relation ... " is >> > processed, the code above doesn't work. >> >> > So, does sqlalchemy support self 2 self relationship ? >> > If the answer is "YES", how to do it? > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@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 -~----------~----~----~----~------~----~------~--~---