[Dbix-class] Issue when prefetching two level deep has_manyrelationships

Hartmaier Alexander Alexander.Hartmaier at t-systems.at
Fri Sep 22 14:39:18 CEST 2006


Hi!

If B does not always has_many C's you have to specify it as an outer join with { join_type => 'LEFT' } in join relationship definition.
You can see an example in the docs above the has_many section:
http://search.cpan.org/~danieltwc/DBIx-Class-0.07002/lib/DBIx/Class/Relationship.pm#has_many


-Alex


> -----Original Message-----
> From: dbix-class-bounces at lists.rawmode.org [mailto:dbix-class-
> bounces at lists.rawmode.org] On Behalf Of Nilson Santos Figueiredo Junior
> Sent: Friday, September 22, 2006 12:41 AM
> To: dbix-class at lists.rawmode.org
> Subject: Re: [Dbix-class] Issue when prefetching two level deep
> has_manyrelationships
> 
> On 9/21/06, Nilson Santos Figueiredo Junior <acid06 at gmail.com> wrote:
> > 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
> >         )
> >     ) { ... }
> 
> No wonder it always succeeds, %co_check is defined as:
> 
> my %co_check = map { ($_, $tree->[0]->{$_}); } @co_key;
> 
> I think this probably means more than one level deep has_many
> relationships are really broken. In an A has_many B has_many C
> situation, whenever you've got a B that doesn't have any C's, the
> following B rows will magically disappear from your resultset.
> 
> I honestly have no clue on how to fix it, hopefully someone else does.
> I think I've already provided the best information I could on this
> issue. This only affects prefetched has_many relationships.
> 
> -Nilson Santos F. Jr.
> 
> _______________________________________________
> List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
> Wiki: http://dbix-class.shadowcatsystems.co.uk/
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
> Searchable Archive: http://www.mail-archive.com/dbix-
> class at lists.rawmode.org/

*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
T-Systems Austria GesmbH   Rennweg 97-99, 1030 Wien
Handelsgericht Wien, FN 79340b
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
Notice: This e-mail contains information that is confidential and may be privileged.
If you are not the intended recipient, please notify the sender and then delete this e-mail immediately.
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*




More information about the Dbix-class mailing list