self-relationship table bad work child/parent key

Issue #3627 closed
Ramin Farajpour Cami created an issue

Hi, i use one table in above model and insert to database (image 1) and i set breakpoint and i see first record ForeignKey (parent_id=Null ) with id=1 and second record with ForeignKey (parent_id=1) and first record id=1 return list in children in second record but i see (image 2) full children list in first record in sele ,

class Student(Base):

  __tablename__ = 'reltest'

   id = Column(Integer, primary_key=True)
   name = Column(String(50))
   fullname = Column(String(50))
   password = Column(String(50))
   parent_id = Column(Integer, ForeignKey('reltest.id'),index=True)
   children = relationship(lambda: Student)

Comments (3)

  1. Ramin Farajpour Cami reporter

    Thanks, I ask you there is problem on sqlalchemy , I read docs for this , I think should fix issue

  2. Log in to comment