[Bast-commits] r6078 - in DBIx-Class/0.08/branches/count_distinct/t: . count search

arcanez at dev.catalyst.perl.org arcanez at dev.catalyst.perl.org
Fri May 1 06:41:35 GMT 2009


Author: arcanez
Date: 2009-05-01 07:41:34 +0100 (Fri, 01 May 2009)
New Revision: 6078

Modified:
   DBIx-Class/0.08/branches/count_distinct/t/count/count_distinct.t
   DBIx-Class/0.08/branches/count_distinct/t/from_subquery.t
   DBIx-Class/0.08/branches/count_distinct/t/search/subquery.t
Log:
cleanup/fix some broken tests

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-04-30 23:48:14 UTC (rev 6077)
+++ DBIx-Class/0.08/branches/count_distinct/t/count/count_distinct.t	2009-05-01 06:41:34 UTC (rev 6078)
@@ -14,43 +14,44 @@
 plan skip_all => 'needs DBD::SQLite for testing' if $@;
 plan tests => 13;
 
-my $in_rs = $schema->resultset("Tag")->search({ tag => [ 'Blue', 'Shiny' ] });
+my $in_rs = $schema->resultset('Tag')->search({ tag => [ 'Blue', 'Shiny' ] });
+my $rs;
 
-cmp_ok($schema->resultset("Tag")->count({ tag => 'Blue' }),
-           '==', 4, 'Count without DISTINCT');
+$rs = $schema->resultset('Tag')->search({ tag => 'Blue' });
+is($rs->count, 4, 'Count without DISTINCT');
 
-cmp_ok($schema->resultset("Tag")->count({ tag => [ 'Blue', 'Shiny' ] }, { group_by => 'tag' }),
-           '==', 2, 'Count with single column group_by');
+$rs = $schema->resultset('Tag')->search({ tag => [ 'Blue', 'Shiny' ] }, { group_by => 'tag' });
+is($rs->count, 2, 'Count with single column group_by');
 
-cmp_ok($schema->resultset("Tag")->count({ tag => 'Blue' }, { group_by => [ qw/tag cd/ ]}), 
-           '==', 4, 'Count with multiple column group_by');
+$rs = $schema->resultset('Tag')->search({ tag => 'Blue' }, { group_by => [ qw/tag cd/ ]});
+is($rs->count, 4, 'Count with multiple column group_by');
 
-cmp_ok($schema->resultset("Tag")->count({ tag => 'Blue' }, { distinct => 1 }),
-           '==', 4, "Count with single column distinct");
+$rs = $schema->resultset('Tag')->search({ tag => 'Blue' }, { distinct => 1 });
+is($rs->count, 4, 'Count with single column distinct');
 
-cmp_ok($schema->resultset("Tag")->count({ tag => { -in => $in_rs->get_column('tag')->as_query } }),
-           '==', 4, "Count with IN subquery");
+$rs = $schema->resultset('Tag')->search({ tag => { -in => $in_rs->get_column('tag')->as_query } });
+is($rs->count, 4, 'Count with IN subquery');
 
-cmp_ok($schema->resultset("Tag")->count({ tag => { -in => $in_rs->get_column('tag')->as_query } }, { group_by => 'tag' }),
-           '==', 1, "Count with IN subquery with outside group_by");
+$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');
 
-cmp_ok($schema->resultset("Tag")->count({ tag => { -in => $in_rs->get_column('tag')->as_query } }, { distinct => 1 }),
-           '==', 4, "Count with IN subquery with outside distinct");
+$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');
 
-cmp_ok($schema->resultset("Tag")->count({ tag => { -in => $in_rs->get_column('tag')->as_query } }, { distinct => 1, select => 'tag' }),
-           '==', 1, "Count with IN subquery with outside distinct on a single column");
+$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');
 
-cmp_ok($schema->resultset("Tag")->count({ tag => { -in => $in_rs->search({}, { group_by => 'tag' })->get_column('tag')->as_query } }),
-           '==', 4, "Count with IN subquery with single group_by");
+$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');
 
-cmp_ok($schema->resultset("Tag")->count({ tag => { -in => $in_rs->search({}, { group_by => [ qw/tag cd/ ] })->get_column('tag')->as_query } }),
-           '==', 4, "Count with IN subquery with multiple 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');
 
-cmp_ok($schema->resultset("Tag")->count({ tag => \"= 'Blue'" }),
-           '==', 4, "Count without DISTINCT, using literal SQL");
+$rs = $schema->resultset('Tag')->search({ tag => \"= 'Blue'" });
+is($rs->count, 4, 'Count without DISTINCT, using literal SQL');
 
-cmp_ok($schema->resultset("Tag")->count({ tag => \" IN ('Blue', 'Shiny')" }, { group_by => 'tag' }),
-           '==', 2, "Count with literal SQL and single group_by");
+$rs = $schema->resultset('Tag')->search({ tag => \" IN ('Blue', 'Shiny')" }, { group_by => 'tag' });
+is($rs->count, 2, 'Count with literal SQL and single group_by');
 
-cmp_ok($schema->resultset("Tag")->count({ tag => \" IN ('Blue', 'Shiny')" }, { group_by => [ qw/tag cd/ ] }),
-           '==', 6, "Count with literal SQL and multiple group_by");
+$rs = $schema->resultset('Tag')->search({ tag => \" IN ('Blue', 'Shiny')" }, { group_by => [ qw/tag cd/ ] });
+is($rs->count, 6, 'Count with literal SQL and multiple group_by');

Modified: DBIx-Class/0.08/branches/count_distinct/t/from_subquery.t
===================================================================
--- DBIx-Class/0.08/branches/count_distinct/t/from_subquery.t	2009-04-30 23:48:14 UTC (rev 6077)
+++ DBIx-Class/0.08/branches/count_distinct/t/from_subquery.t	2009-05-01 06:41:34 UTC (rev 6078)
@@ -27,7 +27,7 @@
   my ($query, @bind) = @{$$arr};
   is_same_sql_bind(
     $query, \@bind,
-    "SELECT me.cdid,me.artist,me.title,me.year,me.genreid,me.single_track FROM cd me WHERE artist_id IN ( SELECT id FROM artist me LIMIT 1 )",
+    "(SELECT me.cdid,me.artist,me.title,me.year,me.genreid,me.single_track FROM cd me WHERE artist_id IN ( SELECT id FROM artist me LIMIT 1 ))",
     [],
   );
 }
@@ -46,7 +46,7 @@
   my ($query, @bind) = @{$$arr};
   is_same_sql_bind(
     $query, \@bind,
-    "SELECT (SELECT id FROM cd me LIMIT 1) FROM artist me",
+    "(SELECT (SELECT id FROM cd me LIMIT 1) FROM artist me)",
     [],
   );
 }
@@ -65,7 +65,7 @@
   my ($query, @bind) = @{$$arr};
   is_same_sql_bind(
     $query, \@bind,
-    "SELECT me.artistid, me.name, me.rank, me.charfield, (SELECT id FROM cd me LIMIT 1) FROM artist me",
+    "(SELECT me.artistid, me.name, me.rank, me.charfield, (SELECT id FROM cd me LIMIT 1) FROM artist me)",
     [],
   );
 }
@@ -86,8 +86,10 @@
   my ($query, @bind) = @{$$arr};
   is_same_sql_bind(
     $query, \@bind,
-    "SELECT cd2.cdid, cd2.artist, cd2.title, cd2.year, cd2.genreid, cd2.single_track FROM (SELECT me.cdid,me.artist,me.title,me.year,me.genreid,me.single_track FROM cd me WHERE ( id > ? ) ) cd2",
-    [ [ 'id', 20 ] ],
+    "(SELECT cd2.cdid, cd2.artist, cd2.title, cd2.year, cd2.genreid, cd2.single_track FROM (SELECT me.cdid,me.artist,me.title,me.year,me.genreid,me.single_track FROM cd me WHERE ( id > ? ) ) cd2)",
+    [
+      [ 'id', 20 ]
+    ],
   );
 }
 
@@ -104,7 +106,8 @@
   my ($query, @bind) = @{$$arr};
   is_same_sql_bind(
     $query, \@bind,
-    "SELECT me.artistid, me.name, me.rank, me.charfield FROM artist me JOIN (SELECT me.artist as cds_artist FROM cd me) cds ON me.artistid = cds_artist", []
+    "(SELECT me.artistid, me.name, me.rank, me.charfield FROM artist me JOIN (SELECT me.artist as cds_artist FROM cd me) cds ON me.artistid = cds_artist)",
+    []
   );
 
 
@@ -133,14 +136,17 @@
   my ($query, @bind) = @{$$arr};
   is_same_sql_bind(
     $query, \@bind,
-    "SELECT cd2.cdid, cd2.artist, cd2.title, cd2.year, cd2.genreid, cd2.single_track 
+    "(SELECT cd2.cdid, cd2.artist, cd2.title, cd2.year, cd2.genreid, cd2.single_track 
       FROM 
         (SELECT cd3.cdid,cd3.artist,cd3.title,cd3.year,cd3.genreid,cd3.single_track 
           FROM 
             (SELECT me.cdid,me.artist,me.title,me.year,me.genreid,me.single_track 
               FROM cd me WHERE ( id < ? ) ) cd3
-          WHERE ( id > ? ) ) cd2",
-    [ [ 'id', 40 ], [ 'id', 20 ] ],
+          WHERE ( id > ? ) ) cd2)",
+    [
+      [ 'id', 40 ], 
+      [ 'id', 20 ]
+    ],
   );
 
 }
@@ -158,7 +164,7 @@
   my ($query, @bind) = @{$$arr};
   is_same_sql_bind(
     $query, \@bind,
-    "SELECT me.cdid, me.artist, me.title, me.year, me.genreid, me.single_track FROM cd me WHERE year = (SELECT MAX(inner.year) FROM cd inner WHERE artistid = me.artistid)",
+    "(SELECT me.cdid, me.artist, me.title, me.year, me.genreid, me.single_track FROM cd me WHERE year = (SELECT MAX(inner.year) FROM cd inner WHERE artistid = me.artistid))",
     [],
   );
 }
@@ -178,7 +184,7 @@
   my ($query, @bind) = @{$$arr};
   is_same_sql_bind(
     $query, \@bind,
-    "SELECT cd2.cdid, cd2.artist, cd2.title, cd2.year, cd2.genreid, cd2.single_track FROM (SELECT me.cdid,me.artist,me.title,me.year,me.genreid,me.single_track FROM cd me WHERE ( title = ? ) ) cd2",
+    "(SELECT cd2.cdid, cd2.artist, cd2.title, cd2.year, cd2.genreid, cd2.single_track FROM (SELECT me.cdid,me.artist,me.title,me.year,me.genreid,me.single_track FROM cd me WHERE ( title = ? ) ) cd2)",
     [ [ 'title', 'Thriller' ] ],
   );
 }

Modified: DBIx-Class/0.08/branches/count_distinct/t/search/subquery.t
===================================================================
--- DBIx-Class/0.08/branches/count_distinct/t/search/subquery.t	2009-04-30 23:48:14 UTC (rev 6077)
+++ DBIx-Class/0.08/branches/count_distinct/t/search/subquery.t	2009-05-01 06:41:34 UTC (rev 6078)
@@ -85,8 +85,10 @@
   my ($query, @bind) = @{$$arr};
   is_same_sql_bind(
     $query, \@bind,
-    "( SELECT cd2.cdid, cd2.artist, cd2.title, cd2.year, cd2.genreid, cd2.single_track FROM (SELECT me.cdid,me.artist,me.title,me.year,me.genreid,me.single_track FROM cd me WHERE id > 20) cd2 )",
-    [],
+    "( SELECT cd2.cdid, cd2.artist, cd2.title, cd2.year, cd2.genreid, cd2.single_track FROM (SELECT me.cdid,me.artist,me.title,me.year,me.genreid,me.single_track FROM cd me WHERE id > ?) cd2 )",
+    [
+      [ 'id', 20 ]
+    ],
   );
 }
 
@@ -137,10 +139,13 @@
         (SELECT cd3.cdid,cd3.artist,cd3.title,cd3.year,cd3.genreid,cd3.single_track 
           FROM 
             (SELECT me.cdid,me.artist,me.title,me.year,me.genreid,me.single_track 
-              FROM cd me WHERE id < 40) cd3
-          WHERE id > 20) cd2
+              FROM cd me WHERE id < ?) cd3
+          WHERE id > ?) cd2
     )",
-    [],
+    [
+      [ 'id', 40 ], 
+      [ 'id', 20 ]
+    ],
   );
 
 }




More information about the Bast-commits mailing list