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

后端 未结 3 691
不思量自难忘°
不思量自难忘° 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:40

    I'm only currently developing agains 0.4.something, but here's how I'd suggest it:

    db.query(Object).filter(Object.first==value).filter(Object.second==False).all()
    

    I think that's what you are trying to do, right?

    (Note: written in a web browser, not real code!)

提交回复
热议问题