Ticket #836 (closed defect: fixed)

Opened 16 months ago

Last modified 16 months ago

Failure to hydrate multiple left-joined components if a previous set was empty

Reported by: AndySchmitt Owned by: zYne-
Priority: major Milestone: 0.10.3
Component: Query/Hydration Version: 0.10.0
Severity: Keywords:
Cc: Has Test:
Status: Has Patch:

Description (last modified by AndySchmitt) (diff)

This problem can be triggered by creating several classes with the following relationships (class content does not matter):

ClassA hasMany ClassB

ClassB hasOne ClassC

ClassA hasMany ClassD

ClassD hasOne ClassE

And then running a DQL query with the following: FROM ClassA a LEFT JOIN a.ClassB b LEFT JOIN b.ClassC c LEFT JOIN a.ClassD d LEFT JOIN d.ClassE e

If there are no rows in ClassB, but there are rows in ClassD, a.ClassB will have a count of 0 (which is expected), but a.ClassD won't even exist in the hydrated record!

This is because the foreach() loop in Hydrator::hydrateResultSet() does a break if there was no previous parent for a component. In my opinion, this should be a continue, so it can ignore the current component that has no parent, but continue to find additional components that may exist.

The attached patch should fix this behavior. Sorry, I have not run unit tests against this updated version as I'm on a deadline for another project. But the unit tests in my project, which heavily uses query/hydration, all work after running the modified library with this patch.

Attachments

hydrator.patch (0.6 KB) - added by AndySchmitt 16 months ago.
Patch file for Doctrine_Hydrator

Change History

Changed 16 months ago by AndySchmitt

Patch file for Doctrine_Hydrator

Changed 16 months ago by AndySchmitt

  • description modified (diff)

Changed 16 months ago by jwage

  • milestone changed from 0.10.2 to 0.10.3

Does your patch fail any new tests? The problem with that patch is, it makes that piece of code useless

Changed 16 months ago by jwage

  • status changed from new to closed
  • resolution set to fixed

(In [3944]) fixes #836

Note: See TracTickets for help on using tickets.