<p>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" ones if they're flagged as "logically_deleted" (a boolean field of the child table)</p>

<p>For example, if an object "parent" has a "children" relation that has
3 records, but one of them is logically deleted, when I query for "Parent" I'd like SQLA to
fetch the parent object with just two children..<br>
How should I do it? By adding an "and" condition to the primaryjoin
parameter of the relation? (e.g. "<code>Children.parent_id == Parent.id and Children.logically_deleted == False</code>", but is it correct to write "and" in this way?)</p>

<p><strong>Edit:</strong><br>
I managed to do it in this way</p>

<pre><code>children = relation("Children", primaryjoin=and_(id == Children.parent_id, Children.logically_deleted==False))
</code></pre>

<p>but is there a way to use a string as primaryjoin instead?</p>

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!)