Today I learnt about SQL Alchemy relationship filters ⚗️

I was working on an SQLAlchemy project where I wanted to select all the tasks on a list which hadn’t been completed, it turns out this custom relationship filter can be done with the use of primaryjoin parameter. The values provided are Python code rather than raw SQL.

tasks = relationship(
    primaryjoin="and_(, Task.completed==None)",