[Bast-commits] r6935 - DBIx-Class/0.08/trunk/t/count

ijw at dev.catalyst.perl.org ijw at dev.catalyst.perl.org
Thu Jul 2 10:41:01 GMT 2009


Author: ijw
Date: 2009-07-02 10:41:01 +0000 (Thu, 02 Jul 2009)
New Revision: 6935

Modified:
   DBIx-Class/0.08/trunk/t/count/joined.t
Log:
Check fetched rows == count for related resultsets

Modified: DBIx-Class/0.08/trunk/t/count/joined.t
===================================================================
--- DBIx-Class/0.08/trunk/t/count/joined.t	2009-07-02 09:23:48 UTC (rev 6934)
+++ DBIx-Class/0.08/trunk/t/count/joined.t	2009-07-02 10:41:01 UTC (rev 6935)
@@ -7,7 +7,7 @@
 
 use DBICTest;
 
-plan tests => 5;
+plan tests => 9;
 
 my $schema = DBICTest->init_schema();
 
@@ -26,10 +26,21 @@
   "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);
+




More information about the Bast-commits mailing list