fix many-to-many self referential aliasing in PropComparator._join_and_criterion

Issue #987 resolved
Mike Bayer repo owner created an issue
t_accounts = Table('accounts', metadata,
    Column('id', Integer, primary_key=True),
    Column('alias', Text(32), unique=True, nullable=False))
#...

t_friends = Table('friends', metadata,
    Column('account_id', None, ForeignKey('accounts.id'), primary_key=True),
    Column('friend_id', None, ForeignKey('accounts.id'), primary_key=True))


mapper(Account, t_accounts, 
    properties = {                                                     
        '_friends': relation(Account, secondary=t_friends, backref='_friendof',
                    primaryjoin=t_accounts.c.id == t_friends.c.account_id,     
                    secondaryjoin=t_accounts.c.id == t_friends.c.friend_id),   
})


not_friends = Account.query().filter(not_(Account._friendof.contains(user_account0)))

Comments (2)

  1. Log in to comment