[Sqlalchemy-tickets] Issue #3654: inspectable Query (for relationships) (zzzeek/sqlalchemy)
Brought to you by:
zzzeek
From: jvanasco <iss...@bi...> - 2016-02-18 20:19:57
|
New issue 3654: inspectable Query (for relationships) https://bitbucket.org/zzzeek/sqlalchemy/issues/3654/inspectable-query-for-relationships jvanasco: There doesn't seem to be a (public) way to find out if a path has been registered to a query for eager loading. (A non-public way seems to be `query.__dict__['with_options']`) I propose an enhancement to the Query API, which allows a query to be queried for the status of eager loads. In the simplest concept, it would just return a dict where the keys are a stringified path, and the values are the type of load (joinedload vs subqueryload vs contains_eager). If there is no eager loading for a given relationship, then the key is absent. print q.registered_eagers() > {'foo': 'joinedload', 'foo.bar':' subqueryload', 'foo.biz': 'contains_eager'} The use-case is when dealing with generative queries that are loading relationships several layers deep; it becomes increasingly hard to ensure you have a load-strategy for each intermediary relationship.. |