[Dbix-class] Issue when prefetching two level deep has_many relationships
Nilson Santos Figueiredo Junior
acid06 at gmail.com
Thu Sep 21 21:58:53 CEST 2006
Hi everyone,
I'm experiencing an issue I believe to be a DBIC bug. Or maybe it's
just expected behaviour (which would be quite weird).
I have three tables set up so that A has_many B and B has_many C.
If I issue a search using this syntax:
$A->search( undef,
{ prefetch => { B => ['C'] } }
);
It returns bogus results. The weird thing is that the generated query
returns correct results when I run it manually.
However, if add a order_by clause, like this:
$A->search( undef,
{ prefetch => { B => ['C'] }, order_by => 'me.name' }
);
It suddenly starts working alright.
It seems that DBIC's resultset munging thing is getting confused when
things are not ordered. I could provide further info if necessary, but
those are plain has_many relationships, so I suppose it shouldn't be
very hard to reproduce.
If I end up diving into DBIC code and manage to find out anything that
could explain this behaviour I'll try coming up with patch (if that's
the case).
-Nilson Santos F. Jr.
More information about the Dbix-class
mailing list