我在两个模型之间有1:M的关系。我想急切地从我身边的M侧加载最后5个项目。
答案 0 :(得分:0)
stmt = session.query(Address).\
limit(5).\
subquery()
adalias = aliased(Address, stmt)
for user, address in session.query(User, adalias).\
join(adalias, User.addresses):
print user
print address