How should new nodes be added with SQLAlchemy to a tree implemented using the Nested Set Model?
class Category(Base):
__tablename__ = 'categories'
id = Column(Integer, primary_key=True)
name = Column(String(128), nullable=False)
lft = Column(Integer, nullable=False, unique=True)
rgt = Column(Integer, nullable=False, unique=True)
I would need a trigger on the table to assign lft and rgt for the new node and update all other effected nodes, but what is the best way to define the position of the node? I can pass the parent_id of the new node to the constructor, but how would I then communicate the parent_id to the trigger?