Boutran
Boutran

Reputation: 10124

Flask SqlAlchemy 2 table join : how to retrieve rows with both objects

I have the following join :

user = User.query.join(UserEmail).filter_by(address = js['email'].lower()).first()

It works, but I also want the UserEmail in the result row

How would I achieve this ?

Upvotes: 1

Views: 485

Answers (1)

van
van

Reputation: 76962

session.query(User, UserEmail).join(UserEmail).filter(...)

The result is a tuple of (User, UserEmail)

Upvotes: 6

Related Questions