[Bast-commits] r6170 - in DBIx-Class/0.08/branches/count_distinct/t: count resultset

ribasushi at dev.catalyst.perl.org ribasushi at dev.catalyst.perl.org
Thu May 7 17:53:30 GMT 2009


Author: ribasushi
Date: 2009-05-07 17:53:30 +0000 (Thu, 07 May 2009)
New Revision: 6170

Modified:
   DBIx-Class/0.08/branches/count_distinct/t/count/count_distinct.t
   DBIx-Class/0.08/branches/count_distinct/t/resultset/as_query.t
Log:
Adjust tests for the IN fixes

Modified: DBIx-Class/0.08/branches/count_distinct/t/count/count_distinct.t
===================================================================
--- DBIx-Class/0.08/branches/count_distinct/t/count/count_distinct.t	2009-05-07 17:28:29 UTC (rev 6169)
+++ DBIx-Class/0.08/branches/count_distinct/t/count/count_distinct.t	2009-05-07 17:53:30 UTC (rev 6170)
@@ -30,22 +30,28 @@
 is($rs->count, 4, 'Count with single column distinct');
 
 $rs = $schema->resultset('Tag')->search({ tag => { -in => $in_rs->get_column('tag')->as_query } });
-is($rs->count, 4, 'Count with IN subquery');
+#SELECT COUNT( * ) FROM tags me WHERE ( tag IN ( SELECT me.tag FROM tags me WHERE ( ( tag = ? OR tag = ? ) ) ) ): 'Blue', 'Shiny'
+is($rs->count, 6, 'Count with IN subquery');
 
 $rs = $schema->resultset('Tag')->search({ tag => { -in => $in_rs->get_column('tag')->as_query } }, { group_by => 'tag' });
-is($rs->count, 1, 'Count with IN subquery with outside group_by');
+#SELECT COUNT( * ) FROM (SELECT tag FROM tags me WHERE ( tag IN ( SELECT me.tag FROM tags me WHERE ( ( tag = ? OR tag = ? ) ) ) ) GROUP BY tag) mesub: 'Blue', 'Shiny'
+is($rs->count, 2, 'Count with IN subquery with outside group_by');
 
 $rs = $schema->resultset('Tag')->search({ tag => { -in => $in_rs->get_column('tag')->as_query } }, { distinct => 1 });
-is($rs->count, 4, 'Count with IN subquery with outside distinct');
+#SELECT COUNT( * ) FROM (SELECT me.tagid, me.cd, me.tag FROM tags me WHERE ( tag IN ( SELECT me.tag FROM tags me WHERE ( ( tag = ? OR tag = ? ) ) ) ) GROUP BY me.tagid, me.cd, me.tag) mesub: 'Blue', 'Shiny'
+is($rs->count, 6, 'Count with IN subquery with outside distinct');
 
 $rs = $schema->resultset('Tag')->search({ tag => { -in => $in_rs->get_column('tag')->as_query } }, { distinct => 1, select => 'tag' }), 
-is($rs->count, 1, 'Count with IN subquery with outside distinct on a single column');
+#SELECT COUNT( * ) FROM (SELECT tag FROM tags me WHERE ( tag IN ( SELECT me.tag FROM tags me WHERE ( ( tag = ? OR tag = ? ) ) ) ) GROUP BY tag) mesub: 'Blue', 'Shiny'
+is($rs->count, 2, 'Count with IN subquery with outside distinct on a single column');
 
 $rs = $schema->resultset('Tag')->search({ tag => { -in => $in_rs->search({}, { group_by => 'tag' })->get_column('tag')->as_query } });
-is($rs->count, 4, 'Count with IN subquery with single group_by');
+#SELECT COUNT( * ) FROM tags me WHERE ( tag IN ( SELECT me.tag FROM tags me WHERE ( ( tag = ? OR tag = ? ) ) GROUP BY tag ) ): 'Blue', 'Shiny'
+is($rs->count, 6, 'Count with IN subquery with single group_by');
 
 $rs = $schema->resultset('Tag')->search({ tag => { -in => $in_rs->search({}, { group_by => [ qw/tag cd/ ] })->get_column('tag')->as_query } });
-is($rs->count, 4, 'Count with IN subquery with multiple group_by');
+#SELECT COUNT( * ) FROM tags me WHERE ( tag IN ( SELECT me.tag FROM tags me WHERE ( ( tag = ? OR tag = ? ) ) GROUP BY tag, cd ) ): 'Blue', 'Shiny'
+is($rs->count, 6, 'Count with IN subquery with multiple group_by');
 
 $rs = $schema->resultset('Tag')->search({ tag => \"= 'Blue'" });
 is($rs->count, 4, 'Count without DISTINCT, using literal SQL');

Modified: DBIx-Class/0.08/branches/count_distinct/t/resultset/as_query.t
===================================================================
--- DBIx-Class/0.08/branches/count_distinct/t/resultset/as_query.t	2009-05-07 17:28:29 UTC (rev 6169)
+++ DBIx-Class/0.08/branches/count_distinct/t/resultset/as_query.t	2009-05-07 17:53:30 UTC (rev 6170)
@@ -66,12 +66,11 @@
   );
 }
 
-TODO: {
-    local $TODO = 'Needs -paren fixes in SQLA before it can work';
-    my $rs = $schema->resultset("CD")->search(
-        { 'artist.name' => 'Caterwauler McCrae' },
-        { join => [qw/artist/]}
-    );
-    my $subsel_rs = $schema->resultset("CD")->search( { cdid => { IN => $rs->get_column('cdid')->as_query } } );
-    cmp_ok($subsel_rs->count, '==', $rs->count, 'Subselect on PK got the same row count');
+{
+  my $rs = $schema->resultset("CD")->search(
+    { 'artist.name' => 'Caterwauler McCrae' },
+    { join => [qw/artist/]}
+  );
+  my $subsel_rs = $schema->resultset("CD")->search( { cdid => { IN => $rs->get_column('cdid')->as_query } } );
+  is($subsel_rs->count, $rs->count, 'Subselect on PK got the same row count');
 }




More information about the Bast-commits mailing list