I'm running SQLAlchemy with Pyramid. I'm trying to run a query with a custom 'join' condition :
DBSession.query(A)\
.outerjoin(A.b, B.a_id == A.id)\
.all()
however the query fails the following error :
AttributeError: Neither 'BinaryExpression' object nor 'Comparator' object has an attribute 'selectable'
The problem stems from the condition, as if I remove it, the query works :
DBSession.query(A)\
.outerjoin(A.b)\
.all()
I don't understand the problem, as I follow the syntax described in the documentation :
q = session.query(User).join(Address, User.id==Address.user_id)
Does anyone see what's going on ?
Ok I saw it.
If you add a custom condition, the syntax is not .outerjoin(A.b, ...)
, but rather .outerjoin(B, ...)
They should accept both, really
(and the error message could be a little more explicit)