1 BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
11 my $schema = DBICTest->init_schema();
13 my $artist = $schema->resultset ('Artist')->find ({artistid => 1});
14 is ($artist->cds->count, 3, 'Correct number of CDs');
15 is ($artist->cds->search_related ('genre')->count, 1, 'Only one of the cds has a genre');
17 $schema->is_executed_querycount( sub {
18 my $pref = $schema->resultset ('Artist')
19 ->search ({ 'me.artistid' => $artist->id }, { prefetch => { cds => 'genre' } })
22 is ($pref->cds->count, 3, 'Correct number of CDs prefetched');
23 is ($pref->cds->search_related ('genre')->count, 1, 'Only one of the prefetched cds has a prefetched genre');
25 }, 1, 'All happened within one query only');