[Bast-commits] r7161 - in DBIx-Class/0.08/branches/prefetch_redux: . t/count

robkinyon at dev.catalyst.perl.org robkinyon at dev.catalyst.perl.org
Fri Jul 31 20:41:01 GMT 2009


Author: robkinyon
Date: 2009-07-31 20:41:01 +0000 (Fri, 31 Jul 2009)
New Revision: 7161

Modified:
   DBIx-Class/0.08/branches/prefetch_redux/Makefile.PL
   DBIx-Class/0.08/branches/prefetch_redux/t/count/prefetch.t
Log:
Added MooseX::Traits to Makefile.PL

Modified: DBIx-Class/0.08/branches/prefetch_redux/Makefile.PL
===================================================================
--- DBIx-Class/0.08/branches/prefetch_redux/Makefile.PL	2009-07-31 13:52:41 UTC (rev 7160)
+++ DBIx-Class/0.08/branches/prefetch_redux/Makefile.PL	2009-07-31 20:41:01 UTC (rev 7161)
@@ -86,6 +86,7 @@
   # t/93storage_replication.t
   'Moose',                    => 0.87,
   'MooseX::AttributeHelpers'  => 0.21,
+  'MooseX::Traits',           => 0.06,
   'MooseX::Types',            => 0.16,
   'namespace::clean'          => 0.11,
   'Hash::Merge',              => 0.11,

Modified: DBIx-Class/0.08/branches/prefetch_redux/t/count/prefetch.t
===================================================================
--- DBIx-Class/0.08/branches/prefetch_redux/t/count/prefetch.t	2009-07-31 13:52:41 UTC (rev 7160)
+++ DBIx-Class/0.08/branches/prefetch_redux/t/count/prefetch.t	2009-07-31 20:41:01 UTC (rev 7161)
@@ -8,7 +8,7 @@
 use DBIC::SqlMakerTest;
 use DBIC::DebugObj;
 
-plan tests => 6;
+plan tests => 9;
 
 my $schema = DBICTest->init_schema();
 
@@ -37,6 +37,31 @@
   );
 }
 
+# collapsing prefetch with distinct
+{
+  my $rs = $schema->resultset("Artist")->search(undef, {distinct => 1})
+            ->search_related('cds')->search_related('genre',
+                { 'genre.name' => 'foo' },
+                { prefetch => q(cds) },
+            );
+  is ($rs->all, 5, 'Correct number of objects');
+
+
+  my ($sql, @bind);
+  $schema->storage->debugobj(DBIC::DebugObj->new(\$sql, \@bind));
+  $schema->storage->debug(1);
+
+
+  is ($rs->count, 5, 'Correct count');
+
+  is_same_sql_bind (
+    $sql,
+    \@bind,
+    'SELECT COUNT( * ) FROM (SELECT cds.cdid FROM artist me JOIN cd cds ON cds.artist = me.artistid LEFT JOIN track tracks ON tracks.cd = cds.cdid JOIN artist artist ON artist.artistid = cds.artist WHERE tracks.position = ? OR tracks.position = ? GROUP BY cds.cdid) count_subq',
+    [ qw/'1' '2'/ ],
+  );
+}
+
 # non-collapsing prefetch (no multi prefetches)
 {
   my $rs = $schema->resultset("CD")




More information about the Bast-commits mailing list