SQLAlchemy: eager loading of more than one relationship

后端 未结 1 1950
旧巷少年郎
旧巷少年郎 2021-02-12 11:50

I want to query this structure:

A -> B
B -> C
B -> D

what\'s the syntax to do this with the Load interface, the documentation is not v

相关标签:
1条回答
  • 2021-02-12 12:27

    Just add another .options(...) with a new relationship path:

    q = (
        session
        .query(A)
        .options(joinedload(A.b).joinedload(B.c))
        .options(joinedload(A.b).joinedload(B.d))
    )
    
    0 讨论(0)
提交回复
热议问题