It is barely possible to do. The usual descriptor approach to an exotic join
condition, in case you'd like to keep things simple, is:
class Node(Base):
@property
def children(self):
return object_session(self).query(Node).filter(Node.id.like(self.id +
'_')).all()
Otherwise,
Hi sqlalchemy-group,
Is it possible to define a self-referential relationship on a join
condition involving the same column on both sides? This:
class Node(Base):
__tablename__ = 'nodes'
id = Column(String(8), primary_key=True)
Node2 = aliased(Node)
Node.children = relationship(Node2,