I have some sqlalchemy query:
>>> items = (
Company.query
.add_column(Address.city)
.join(Company.address)
.filter(and_(
...some filters...
))
.all()
)
>>> items
[(Company(6239), Berlin), (Company(5388), Moscow), ...]
How can I modify my query, to put Address.city to entity Company?
I want it to look as:
...
>>> items
[Company(6239), Company(5388), ...]
>>> items[0].city
Berlin
Thank you.
I do not think you can do it directly in a query without modifying the model.
But you can easily achive this in the code: