[Bast-commits] r6937 - DBIx-Class/0.08/trunk/t/prefetch
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Thu Jul 2 10:52:51 GMT 2009
Author: ribasushi
Date: 2009-07-02 10:52:51 +0000 (Thu, 02 Jul 2009)
New Revision: 6937
Modified:
DBIx-Class/0.08/trunk/t/prefetch/count.t
Log:
More fail (fix is known but needs work)
Modified: DBIx-Class/0.08/trunk/t/prefetch/count.t
===================================================================
--- DBIx-Class/0.08/trunk/t/prefetch/count.t 2009-07-02 10:43:47 UTC (rev 6936)
+++ DBIx-Class/0.08/trunk/t/prefetch/count.t 2009-07-02 10:52:51 UTC (rev 6937)
@@ -5,7 +5,7 @@
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')->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)");
+
More information about the Bast-commits
mailing list