Skip to content

Is there a way to use attributes on a relationship attribute when selecting models using where? #1492

Answered by byrman
taranlu-houzz asked this question in Questions
Discussion options

You must be logged in to vote

Yes, there is a way:

db_statement = select(Product).where(Product.source.has(another_attribute = False))

But if you inspect the generated SQL, you'll see that you are probably better off using a join.

Replies: 4 comments 1 reply

Comment options

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

Answer selected by YuriiMotov
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
3 participants
Converted from issue

This discussion was converted from issue #261 on August 12, 2025 10:35.