Ticket #952 (closed defect: fixed)

Opened 15 months ago

Last modified 9 months ago

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

Changed 13 months ago by tuct

@dball use doctrine together with symfony, u cann see all queries in the _dev toolbar :)

Changed 13 months ago by romanb

Please provide a testcase for this issue.

Changed 12 months ago by jwage

  • has_patch unset
  • mystatus set to Pending Core Response
  • has_test unset

Added test coverage in r4583

Changed 12 months ago by romanb

  • milestone changed from 0.11.1 to 1.0.0-BETA1

Changed 10 months ago by jwage

  • version changed from 0.10 to 1.0
  • milestone changed from Unknown to 1.0.0-RC2

Changed 10 months ago by anonymous

  • milestone New deleted

Milestone New deleted

Changed 10 months ago by jwage

  • milestone set to 1.0.3

Changed 9 months ago by jwage

  • milestone changed from 1.0.3 to 1.0.4

Changed 9 months ago by jwage

  • status changed from new to closed
  • version changed from 1.0.0 to 1.0.2
  • resolution set to fixed
  • milestone changed from 1.0.4 to 1.0.3

In r5047 this was fixed.

Note: See TracTickets for help on using tickets.