of all the A's pointed to by a given B. I specifically want this to be a relationship so that I can prefetch it with

joinedload

to avoid a case where we now have O(N) queries.

When I try to preload the

maximum_a

relationship (e.g. via

session.query(B).options(joinedload('maximum_a')).all()

), I get the following error:

sqlalchemy.exc.InvalidRequestError: Select statement 'SELECT max(a_1.a_id) AS max_1
FROM a AS a_1, b
WHERE a_1.a_remote = b.foreign_to_a' returned no FROM clauses due to auto-correlation; specify correlate(<tables>) to control correlation manually.

I've tried to read the SQLA docs on correlation, but they're all written in terms of the raw

select

rather than ORM calls, and the descriptions are not very clear, so I'm not sure where to add the