[Dbix-class] Issue when prefetching two level deep has_many relationships

Nilson Santos Figueiredo Junior acid06 at gmail.com
Fri Sep 22 00:29:04 CEST 2006


On 9/21/06, Nilson Santos Figueiredo Junior <acid06 at gmail.com> wrote:
> I don't really think I'll be able to fix this, but I've confirmed it's
> a bug and apparently the problem resides somewhere inside ResultSet.pm
> _collapse_result() method. Since it's a recursive, one hundred lines
> method, I'm completely lost inside it.
>
> Uncommenting the "Dumper" line at the end of the method I was able to
> notice that although it finds the B and C related rows it ends up not
> building the A row. I could provide this dump if it's useful.

I further dove into the code and I've found exactly where the problem
is inside the _collapse_result() method. The following check should
fail, however it succeeds:

    while (
      !(
        grep {
          !defined($tree->[0]->{$_}) || $co_check{$_} ne $tree->[0]->{$_}
        } @co_key
        )
    ) { ... }

That makes one object "eat" rows of the following one. I still
couldn't come up with a fix though, but this information should
probably make it for someone experienced with DBIC guts to fix it
quickly. The problem is that $co_check{$_} is equal to
$tree->[0]->{$_} when it shouldn't be. $co_check{$_} got loaded with
the id of the current object so they'd always be equal.

-Nilson Santos F. Jr.



More information about the Dbix-class mailing list