KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a class Node with a self referential mapping 'children' (backref 'parent') representing a tree in SQLAlchemy and I want to select the entire tree. If I do session.query(Node).all() then every access to node.children triggers a select. If I do a joined load session.query(Node).options(joinedload_all('children')).all() then the sql issued has an unnecessary table join since I want the entire tree (all nodes) anyways. Is there a way to do this in SA or should I just construct the tree on my own outside of SA?
Tags (comma-separated)
Save Edits
Cancel