How to add an automatic filter to a relation with SQLAlchemy?

后端 未结 3 690
不思量自难忘°
不思量自难忘° 2021-02-08 09:54

I\'m using SQLAlchemy 0.5rc, and I\'d like to add an automatic filter to a relation, so that every time it tries to fetch records for that relation, it ignores the \"remote\" on

3条回答
  •  臣服心动
    2021-02-08 10:54

    but is there a way to use a string as primaryjoin instead?

    You can use the following:

    children = relationship("Children", primaryjoin="and_(Parent.id==Children.parent_id, Children.logically_deleted==False)"
    

    This worked for me!

提交回复
热议问题