[Bast-commits] r5447 - DBIx-Class/0.08/trunk/t

ribasushi at dev.catalyst.perl.org ribasushi at dev.catalyst.perl.org
Wed Feb 11 09:02:42 GMT 2009


Author: ribasushi
Date: 2009-02-11 09:02:42 +0000 (Wed, 11 Feb 2009)
New Revision: 5447

Modified:
   DBIx-Class/0.08/trunk/t/77prefetch.t
Log:
Add a weird extra test, that should work nevertheless

Modified: DBIx-Class/0.08/trunk/t/77prefetch.t
===================================================================
--- DBIx-Class/0.08/trunk/t/77prefetch.t	2009-02-11 08:24:58 UTC (rev 5446)
+++ DBIx-Class/0.08/trunk/t/77prefetch.t	2009-02-11 09:02:42 UTC (rev 5447)
@@ -17,7 +17,7 @@
     eval "use DBD::SQLite";
     plan $@
         ? ( skip_all => 'needs DBD::SQLite for testing' )
-        : ( tests => 63 );
+        : ( tests => 68 );
 }
 
 # figure out if we've got a version of sqlite that is older than 3.2.6, in
@@ -49,9 +49,12 @@
 # A search() with prefetch seems to pollute an already joined resultset
 # in a way that offsets future joins (adapted from a test case by Debolaz)
 {
-  my $cd_rs = $schema->resultset ('Producer')->first->cds;
-  my $attrs = Dumper $cd_rs->{attrs};
+  my ($cd_rs, $attrs);
 
+  # test a real-life case - rs is obtained by an implicit m2m join
+  $cd_rs = $schema->resultset ('Producer')->first->cds;
+  $attrs = Dumper $cd_rs->{attrs};
+
   $cd_rs->search ({})->all;
   is (Dumper ($cd_rs->{attrs}), $attrs, 'Resultset attributes preserved after a simple search');
 
@@ -64,6 +67,25 @@
     $cd_rs->search ({'artist.artistid' => 1}, { prefetch => 'artist' })->all;
     is (Dumper ($cd_rs->{attrs}), $attrs, 'Resultset attributes preserved after another search with prefetch')
   }, 'second prefetching search ok');
+
+
+  # test a regular rs with an empty seen_join injected - it should still work!
+  $cd_rs = $schema->resultset ('CD');
+  $cd_rs->{attrs}{seen_join}  = {};
+  $attrs = Dumper $cd_rs->{attrs};
+
+  $cd_rs->search ({})->all;
+  is (Dumper ($cd_rs->{attrs}), $attrs, 'Resultset attributes preserved after a simple search');
+
+  lives_ok (sub {
+    $cd_rs->search ({'artist.artistid' => 1}, { prefetch => 'artist' })->all;
+    is (Dumper ($cd_rs->{attrs}), $attrs, 'Resultset attributes preserved after search with prefetch');
+  }, 'first prefetching search ok');
+
+  lives_ok (sub {
+    $cd_rs->search ({'artist.artistid' => 1}, { prefetch => 'artist' })->all;
+    is (Dumper ($cd_rs->{attrs}), $attrs, 'Resultset attributes preserved after another search with prefetch')
+  }, 'second prefetching search ok');
 }
 
 




More information about the Bast-commits mailing list