Ticket #952 (closed defect: fixed)
When eagerly loading a parent and its children, the childrens' parent references are not set
| Reported by: | dball | Owned by: | romanb |
|---|---|---|---|
| Priority: | minor | Milestone: | 1.0.3 |
| Component: | Query/Hydration | Version: | 1.0.2 |
| Severity: | Keywords: | hydration relations references | |
| Cc: | Has Test: | no | |
| Status: | Pending Core Response | Has Patch: | no |
Description
$parent = $query->from('Parent p')->leftJoin('p.Children')->execute()->first();
echo $parent['Children'][0]['Parent']['id'];
The second line will trigger doctrine to unnecessarily load a new instance of the parent from the database.
Also, when the query is run in HYDRATE_ARRAY mode, the child array contains no key for the parent, although I suppose this could be by design in order to avoid cyclic graphs.
Finally, a suggestion: it would be cool if doctrine could be configured to print a stacktrace whenever it lazily loads some data, to enable those of us developing for performance to more easily spot our mistakes.
Change History
Note: See
TracTickets for help on using
tickets.