[Sqlalchemy-tickets] Issue #3056: Materialized path relationship: `lazy="subquery"` not working whi
Brought to you by:
zzzeek
|
From: Jack Z. <iss...@bi...> - 2014-05-20 03:08:43
|
New issue 3056: Materialized path relationship: `lazy="subquery"` not working while `subqueryload()` works https://bitbucket.org/zzzeek/sqlalchemy/issue/3056/materialized-path-relationship-lazy Jack Zhou: Reference: http://stackoverflow.com/questions/23054398/materialized-path-relationship-in-declarative-sqlalchemy/23176477#comment36511621_23176477 The configuration: ``` #!python class Node(Base): __tablename__ = "node" id = Column(Integer, primary_key=True) path = Column(String(500), nullable=False) children = relationship( "Node", primaryjoin=remote(foreign(path)).like(path.concat(".%")), viewonly=True, lazy="subquery") ``` The query: ``` #!python db.add(Node(path="foo")) db.add(Node(path="foo.bar")) db.add(Node(path="foo.bar.baz")) db.flush() db.query(Node).all() # issues one SELECT to find all nodes db.query(Node).options(subqueryload(Node.children)).all() # issues two SELECTs to find all nodes and their children ``` The `lazy="subquery"` declaration does not seem to have any effect. |