[Bast-commits] r6447 - in DBIx-Class/0.08/trunk: lib/DBIx/Class t/prefetch

ribasushi at dev.catalyst.perl.org ribasushi at dev.catalyst.perl.org
Thu May 28 11:02:22 GMT 2009


Author: ribasushi
Date: 2009-05-28 11:02:22 +0000 (Thu, 28 May 2009)
New Revision: 6447

Modified:
   DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSource.pm
   DBIx-Class/0.08/trunk/t/prefetch/multiple_hasmany.t
Log:
Fix multiprefetch warning - we can now count properly

Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSource.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSource.pm	2009-05-28 08:20:57 UTC (rev 6446)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSource.pm	2009-05-28 11:02:22 UTC (rev 6447)
@@ -1274,8 +1274,7 @@
             ? "at the same level (${as_prefix}) "
             : "at top level "
           )
-          . 'will currently disrupt both the functionality of $rs->count(), '
-          . 'and the amount of objects retrievable via $rs->next(). '
+          . 'will explode the number of row objects retrievable via ->next or ->all. '
           . 'Use at your own risk.'
         );
       }
@@ -1360,8 +1359,7 @@
             ? "at the same level (${as_prefix}) "
             : "at top level "
           )
-          . 'will currently disrupt both the functionality of $rs->count(), '
-          . 'and the amount of objects retrievable via $rs->next(). '
+          . 'will explode the number of row objects retrievable via ->next or ->all. '
           . 'Use at your own risk.'
         );
       }

Modified: DBIx-Class/0.08/trunk/t/prefetch/multiple_hasmany.t
===================================================================
--- DBIx-Class/0.08/trunk/t/prefetch/multiple_hasmany.t	2009-05-28 08:20:57 UTC (rev 6446)
+++ DBIx-Class/0.08/trunk/t/prefetch/multiple_hasmany.t	2009-05-28 11:02:22 UTC (rev 6447)
@@ -7,19 +7,12 @@
 use DBICTest;
 use Data::Dumper;
 
+plan tests => 10;
+
 my $schema = DBICTest->init_schema();
 
-my $orig_debug = $schema->storage->debug;
-
 use IO::File;
 
-BEGIN {
-    eval "use DBD::SQLite";
-    plan $@
-        ? ( skip_all => 'needs DBD::SQLite for testing' )
-        : ( tests => 16 );
-}
-
 # once the following TODO is complete, remove the 2 warning tests immediately
 # after the TODO block
 # (the TODO block itself contains tests ensuring that the warns are removed)
@@ -97,24 +90,21 @@
 }
 
 # remove this closure once the TODO above is working
-my $w;
 {
-    local $SIG{__WARN__} = sub { $w = shift };
+    my $warn_re = qr/will explode the number of row objects retrievable via/;
 
+    my (@w, @dummy);
+    local $SIG{__WARN__} = sub { $_[0] =~ $warn_re ? push @w, @_ : warn @_ };
+
     my $rs = $schema->resultset('CD')->search ({ 'me.title' => 'Forkful of bees' }, { prefetch => [qw/tracks tags/] });
-    for (qw/all count next first/) {
-        undef $w;
-        my @stuff = $rs->search()->$_;
-        like ($w, qr/will currently disrupt both the functionality of .rs->count\(\), and the amount of objects retrievable via .rs->next\(\)/,
-            "warning on ->$_ attempt prefetching several same level has_manys (1 -> M + M)");
-    }
+    @w = ();
+    @dummy = $rs->first;
+    is (@w, 1, 'warning on attempt prefetching several same level has_manys (1 -> M + M)');
+
     my $rs2 = $schema->resultset('LinerNotes')->search ({ notes => 'Buy Whiskey!' }, { prefetch => { cd => [qw/tags tracks/] } });
-    for (qw/all count next first/) {
-        undef $w;
-        my @stuff = $rs2->search()->$_;
-        like ($w, qr/will currently disrupt both the functionality of .rs->count\(\), and the amount of objects retrievable via .rs->next\(\)/,
-            "warning on ->$_ attempt prefetching several same level has_manys (M -> 1 -> M + M)");
-    }
+    @w = ();
+    @dummy = $rs2->first;
+    is (@w, 1, 'warning on attempt prefetching several same level has_manys (M -> 1 -> M + M)');
 }
 
 __END__




More information about the Bast-commits mailing list