[Dbix-class] Can't modify prefetch
Ryan Tate
ryantate at ryantate.com
Sat Nov 27 00:24:29 GMT 2010
It appears if you specify prefetch twice on the same resultset, only
the first one sticks. E.g.:
my $rs = $schema->resultset('Artist')->search( {},
{prefetch => ['cds'],}
);
$rs->search({},
{prefetch => ['stalkers'],}
);
According to the docs, prefetches are supposed to be merged in this
scenario <http://search.cpan.org/~frew/DBIx-Class-
0.08124/lib/DBIx/Class/ResultSet.pm#Resolving_conditions_and_attributes>
If you monitor the SQL that gets executed, the first prefetch ("cds")
sticks but the second prefetch ("stalkers") doesn't get executed, and
DBIx::Class will go to the database every time you call it on the
fetched items ($artist->stalkers->first).
There's a failing test case here
http://ryantate.com/transfer/dbixc_prefetch.t.txt
And I added an RT entry here
https://rt.cpan.org/Public/Bug/Display.html?id=63360
More information about the DBIx-Class
mailing list