[Dbix-class] multiple has_many rels in prefetch not supported in 0.081?

Moritz Onken onken at houseofdesign.de
Sat Aug 23 07:53:27 BST 2008


Am 22.08.2008 um 23:42 schrieb Peter Rabbitson:

> Moritz Onken wrote:
>> Hi,
>>
>> I installed the latest svn revision of DBIx-Class-0.08099_04 and my  
>> code
>> fails serval times because I prefetch multiple has_many rels. This  
>> was
>> no problem with 0.08010. Why did you change this behaviour? I didn't
>> read anything about this on thsi list.
>> I have to change a lot of code for 0.081 and it makes it even slower
>> because my application needs to hit the database even more.
>>
>> Hope someone can explain why this happened.
>
> As mst said it never worked in the first place. I was the one who  
> wrote
> the failing tests for this. To see for yourself:
>
> svn co http://dev.catalyst.perl.org/repos/bast/DBIx-Class/0.08/trunk
> dbic -r 4433
> cd dbic
> perl Makefile.PL
> make
> prove -v -Ilib t/77prefetch.t
>
> Enjoy the fireworks :)

Something like:

my $search = {  };
my $attr = { prefetch => [ qw/tracks tags/ ] };

my $cd = $schema->resultset("Artist")->first->cds->search($search,  
$attr)->first;
$cd->tracks->all;
$cd->tags->all;

did work for me. If you say it breaks in many cases I might have not
tested it enough.
Is there an alternative to get the same data with one query but still
have all the relations working?

moritz



More information about the DBIx-Class mailing list