I've got a schema that I was having problems with last night.  I got
it working, but, it seems somewhat dangerous unless I force lazy
loading:


class User(Base):
    __tablename__ = 'xxx_users'

    fb_uid = Column(mysql.MSBigInteger(20, unsigned=True),
primary_key=True)

    friends = relation('User_friend',
primaryjoin='User.fb_uid==User_friend.user_id')


class User_friend(Base):
    __tablename__ = 'xxx_user_users'

    uu_id = Column(mysql.MSBigInteger(20, unsigned = True),
primary_key=True)
    user_id = Column(mysql.MSBigInteger(20, unsigned = True),
ForeignKey(User.fb_uid))
    friend_id = Column(mysql.MSBigInteger(20, unsigned = True),
ForeignKey(User.fb_uid))

    friend = relation('User',
primaryjoin='User_friend.friend_id==User.fb_uid', uselist=False)


I have a User table that is grabbing the list of friends, referenced
back to the original User table.  Since there is a relation, I could
endlessly recurse, though, my template doesn't allow that.  i.e. if a
user has a friend that has the original user as a friend.  Is this
going to cause issues later?  I think using beaker to cache this might
force a non-lazy load which could have problems.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@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.

Reply via email to