From: Peter Rabbitson Date: Thu, 2 Jul 2009 10:52:51 +0000 (+0000) Subject: More fail (fix is known but needs work) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=610e8c9868fd6422bdd26c7973c35f66b3c9b4e7;p=dbsrgits%2FDBIx-Class-Historic.git More fail (fix is known but needs work) --- diff --git a/t/prefetch/count.t b/t/prefetch/count.t index df24d5c..30aed7e 100644 --- a/t/prefetch/count.t +++ b/t/prefetch/count.t @@ -5,7 +5,7 @@ use Test::More; use lib qw(t/lib); use DBICTest; -plan tests => 9; +plan tests => 11; my $schema = DBICTest->init_schema(); @@ -23,10 +23,20 @@ is($cd_rs->search_related('tracks')->count, 15, 'Tracks associated with CDs coun is($cd_rs->search_related ('tracks')->all, 15, 'Track objects associated with CDs (after SELECT()ing)'); -my $artist=$schema->resultset('Artist')->create({name => 'xxx'}); -my $artist_rs = $schema->resultset('Artist')->search({artistid => $artist->id}, {prefetch=>'cds'}); +my $artist = $schema->resultset('Artist')->create({name => 'xxx'}); + +my $artist_rs = $schema->resultset('Artist')->search( + {artistid => $artist->id}, + {prefetch=>'cds', join => 'twokeys' } +); + is($artist_rs->count, 1, "New artist found with prefetch turned on"); is(scalar($artist_rs->all), 1, "New artist fetched with prefetch turned on"); is($artist_rs->related_resultset('cds')->count, 0, "No CDs counted on a brand new artist"); is(scalar($artist_rs->related_resultset('cds')->all), 0, "No CDs fetched on a brand new artist (count == fetch)"); +# create a cd, and make sure the non-existing join does not skew the count +$artist->create_related ('cds', { title => 'yyy', year => '1999' }); +is($artist_rs->related_resultset('cds')->count, 1, "1 CDs counted on a brand new artist"); +is(scalar($artist_rs->related_resultset('cds')->all), 1, "1 CDs prefetched on a brand new artist (count == fetch)"); +