Fred C escribió: > Hi, > > I have a class User and I want to have a friends relation ship > between users in that table. > Is it possible to do it like in the snippet bellow. Is there a better > way to do it with SQLObject? > > I have tested this. and it works, but this construction doesn't fee > right to me. Also the problems is that I have to do two add, > u1.addUser(u2), u2.addUser(u1) to have the complete relation. Maybe > whit a different construction I can do it in one operation. > > class User(SQLObject): > user_name = UnicodeCol(length=16, alternateID=True) > display_name = UnicodeCol(length=255) > ... > friends = RelatedJoin('User', intermediateTable='user_user', > joinColumn='user_id', otherColumn='id') >
I think you can do: class User(SQLObject): ... friends = RelatedJoin('User', intermediateTable='user_user', joinColumn='user1_id', otherColumn='user2_id', createRelatedTable = False) class UserUser(SQLObject): user1 = ForeignKey('User') user2 = ForeignKey('User') and then create the relation: UserUser(u1, u2) > > Thanks for your suggestions > -fred- > > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > sqlobject-discuss mailing list > sqlobject-discuss@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss > > ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ sqlobject-discuss mailing list sqlobject-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss