From: Ian Wells Date: Wed, 1 Jul 2009 18:04:16 +0000 (+0000) Subject: Additional tests on prefetch - illustrates the bug with left-join has_many (NULL... X-Git-Tag: v0.08108~33 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1ec6e7c25e6956b72d05265b43c5be735614bd28;p=dbsrgits%2FDBIx-Class.git Additional tests on prefetch - illustrates the bug with left-join has_many (NULL row returned) and the one that results from the trivial fix (prefetch gives no artist) --- diff --git a/t/prefetch/count.t b/t/prefetch/count.t index fac478c..d554abd 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 => 5; +plan tests => 7; my $schema = DBICTest->init_schema(); @@ -22,3 +22,10 @@ is($cd_rs->all, 5, 'Amount of CD objects with tracks'); is($cd_rs->search_related('tracks')->count, 15, 'Tracks associated with CDs count (after SELECT()ing)'); 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'}); +is($artist_rs->related_resultset('cds')->count, 0, "No CDs on a brand new artist"); +is($artist_rs->count, 1, + "No CDs prefetched but the artist is still returned"); +