[Bast-commits] r5702 - DBIx-Class/0.08/branches/prefetch/t/prefetch

ribasushi at dev.catalyst.perl.org ribasushi at dev.catalyst.perl.org
Fri Mar 6 22:06:23 GMT 2009


Author: ribasushi
Date: 2009-03-06 22:06:23 +0000 (Fri, 06 Mar 2009)
New Revision: 5702

Modified:
   DBIx-Class/0.08/branches/prefetch/t/prefetch/multiple_hasmany.t
Log:
Illustration for rob

Modified: DBIx-Class/0.08/branches/prefetch/t/prefetch/multiple_hasmany.t
===================================================================
--- DBIx-Class/0.08/branches/prefetch/t/prefetch/multiple_hasmany.t	2009-03-06 21:18:09 UTC (rev 5701)
+++ DBIx-Class/0.08/branches/prefetch/t/prefetch/multiple_hasmany.t	2009-03-06 22:06:23 UTC (rev 5702)
@@ -17,21 +17,10 @@
     eval "use DBD::SQLite";
     plan $@
         ? ( skip_all => 'needs DBD::SQLite for testing' )
-        : ( tests => 16 );
+#        : ( tests => 16 );
+        : 'no_plan';
 }
 
-# figure out if we've got a version of sqlite that is older than 3.2.6, in
-# which case COUNT(DISTINCT()) doesn't work
-my $is_broken_sqlite = 0;
-my ($sqlite_major_ver,$sqlite_minor_ver,$sqlite_patch_ver) =
-    split /\./, $schema->storage->dbh->get_info(18);
-if( $schema->storage->dbh->get_info(17) eq 'SQLite' &&
-    ( ($sqlite_major_ver < 3) ||
-      ($sqlite_major_ver == 3 && $sqlite_minor_ver < 2) ||
-      ($sqlite_major_ver == 3 && $sqlite_minor_ver == 2 && $sqlite_patch_ver < 6) ) ) {
-    $is_broken_sqlite = 1;
-}
-
 # 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)
@@ -129,6 +118,54 @@
     }
 }
 
+
+# Illustration purposes only
+
+{
+  package Inf::Dump;
+  sub inflate_result {
+    return [ @_[2,3] ];
+  }
+}
+
+my $cd = $schema->resultset ('CD')->create ({
+  artist => 1,
+  title => 'bad cd',
+  year => 1313,
+  tags => [ map { { tag => "bad tag $_" } } (1 .. 3) ],
+  tracks => [
+    { title => 'bad track 1', cd_single => {
+      artist => 1,
+      title => 'bad_single',
+      year => 1313,
+    }},
+    map { { title => "bad track $_" } } (2 .. 3),
+  ],
+});
+
+my $rs = $schema->resultset ('CD')->search (
+  { 'me.cdid' => $cd->id },
+  { prefetch => [ 'tags', { tracks => 'cd_single' } ], result_class => 'Inf::Dump' },
+);
+
+use Text::Table;
+my ($cols) = ( ${$rs->as_query}->[0] =~ /SELECT (.+) FROM/);
+my $tb = Text::Table->new (map { $_ => \ ' | ' } (split /,\s*/, $cols) );
+
+my $c = $rs->cursor;
+while (my @stuff = $c->next) {
+  $tb->add (map { defined $_ ? $_ : 'NULL' } (@stuff) );
+}
+
+$rs->reset;
+print STDERR Dumper [
+  "\n$tb",
+  $rs->next
+];
+
+
+
+
 __END__
 The solution is to rewrite ResultSet->_collapse_result() and
 ResultSource->resolve_prefetch() to focus on the final results from the collapse




More information about the Bast-commits mailing list