From: Ian Wells Date: Thu, 2 Jul 2009 10:41:01 +0000 (+0000) Subject: Check fetched rows == count for related resultsets X-Git-Tag: v0.08108~29 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b683f3527196bf361b4ac4f4a8c73b80770da0c0;p=dbsrgits%2FDBIx-Class.git Check fetched rows == count for related resultsets --- diff --git a/t/count/joined.t b/t/count/joined.t index 3f0b514..85aff3e 100644 --- a/t/count/joined.t +++ b/t/count/joined.t @@ -7,7 +7,7 @@ use lib qw(t/lib); use DBICTest; -plan tests => 5; +plan tests => 9; my $schema = DBICTest->init_schema(); @@ -26,10 +26,21 @@ is ( "Count correct with requested distinct collapse of main table" ); +# JOIN and LEFT JOIN issues mean that we've seen problems where counted rows and fetched rows are sometimes 1 higher than they should +# be in the related resultset. my $artist=$schema->resultset('Artist')->create({name => 'xxx'}); -is($artist->related_resultset('cds')->count(), 0, - "No CDs found for a shiny new artist"); +is($artist->related_resultset('cds')->count(), 0, "No CDs found for a shiny new artist"); +is(scalar($artist->related_resultset('cds')->all()), 0, "No CDs fetched for a shiny new artist"); + my $artist_rs = $schema->resultset('Artist')->search({artistid => $artist->id}); -is($artist_rs->related_resultset('cds')->count(), 0, - "No CDs found for a shiny new artist using a resultset search"); +is($artist_rs->related_resultset('cds')->count(), 0, "No CDs counted for a shiny new artist using a resultset search"); +is(scalar($artist_rs->related_resultset('cds')->all), 0, "No CDs fetched for a shiny new artist using a resultset search"); + +$artist->cds->create({}); +is($artist->related_resultset('cds')->count(), 1); +is(scalar($artist->related_resultset('cds')->all()), 1); + +$artist_rs = $schema->resultset('Artist')->search({artistid => $artist->id}); +is($artist_rs->related_resultset('cds')->count(), 1); +is(scalar($artist_rs->related_resultset('cds')->all), 1);