Skip to content

Query.filter.options(load_only) difference in behaviour from sqlalchemy 1.4 onwards #11338

Discussion options

You must be logged in to vote

I could re-write the expression above as a join instead of a IN clause, and in the example above that would be fairly straight-forward, but not so much in the actual legacy code base I need to migrate.

there's no need for that, simply write subqueries naturally, e.g.

subq = session().query(Parent.id).filter(Parent.id < 10)
q = session().query(Parent).join(Child).filter(Parent.id.in_(subq))

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@zzzeek
Comment options

Answer selected by joaocosta
Comment options

You must be logged in to vote
1 reply
@zzzeek
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants