- changed status to duplicate
inspectable Query (for relationships)
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..
Comments (4)
-
repo owner -
repo owner we have a long term plan for an inspectable query at #3225.
-
reporter Ah, sorry. Well here's another use-case!
FWIW, I did spent about 30 minutes searching though back tickets for possible dupes, but I didn't see the query inspection one. I was focused on the eager loading keywords.
-
repo owner all of that goes into switch to phabricator. bitbucket issues intentionally sucks b.c. they want to sell Jira (which also sucks).
- Log in to comment
Duplicate of #3225.