12 my $schema = DBICTest->init_schema();
14 my $cds = $schema->resultset("CD")->search({ cdid => 1 }, { join => { cd_to_producer => 'producer' } });
15 cmp_ok($cds->count, '>', 1, "extra joins explode entity count");
18 $cds->search({}, { prefetch => 'cd_to_producer' })->count,
20 "Count correct with extra joins collapsed by prefetch"
24 $cds->search({}, { distinct => 1 })->count,
26 "Count correct with requested distinct collapse of main table"
29 # JOIN and LEFT JOIN issues mean that we've seen problems where counted rows and fetched rows are sometimes 1 higher than they should
30 # be in the related resultset.
31 my $artist=$schema->resultset('Artist')->create({name => 'xxx'});
32 is($artist->related_resultset('cds')->count(), 0, "No CDs found for a shiny new artist");
33 is(scalar($artist->related_resultset('cds')->all()), 0, "No CDs fetched for a shiny new artist");
35 my $artist_rs = $schema->resultset('Artist')->search({artistid => $artist->id});
36 is($artist_rs->related_resultset('cds')->count(), 0, "No CDs counted for a shiny new artist using a resultset search");
37 is(scalar($artist_rs->related_resultset('cds')->all), 0, "No CDs fetched for a shiny new artist using a resultset search");