9 my $schema = DBICTest->init_schema();
11 my $artist = $schema->resultset ('Artist')->find ({artistid => 1});
12 is ($artist->cds->count, 3, 'Correct number of CDs');
13 is ($artist->cds->search_related ('genre')->count, 1, 'Only one of the cds has a genre');
15 $schema->is_executed_querycount( sub {
16 my $pref = $schema->resultset ('Artist')
17 ->search ({ 'me.artistid' => $artist->id }, { prefetch => { cds => 'genre' } })
20 is ($pref->cds->count, 3, 'Correct number of CDs prefetched');
21 is ($pref->cds->search_related ('genre')->count, 1, 'Only one of the prefetched cds has a prefetched genre');
23 }, 1, 'All happened within one query only');