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

ribasushi at dev.catalyst.perl.org ribasushi at dev.catalyst.perl.org
Thu Apr 30 07:10:36 GMT 2009


Author: ribasushi
Date: 2009-04-30 08:10:36 +0100 (Thu, 30 Apr 2009)
New Revision: 6034

Added:
   DBIx-Class/0.08/branches/count_distinct/t/count/
   DBIx-Class/0.08/branches/count_distinct/t/count/count_distinct.t
   DBIx-Class/0.08/branches/count_distinct/t/count/count_joined.t
Removed:
   DBIx-Class/0.08/branches/count_distinct/t/count_distinct.t
Log:
Add joined count test

Copied: DBIx-Class/0.08/branches/count_distinct/t/count/count_distinct.t (from rev 5849, DBIx-Class/0.08/branches/count_distinct/t/count_distinct.t)
===================================================================
--- DBIx-Class/0.08/branches/count_distinct/t/count/count_distinct.t	                        (rev 0)
+++ DBIx-Class/0.08/branches/count_distinct/t/count/count_distinct.t	2009-04-30 07:10:36 UTC (rev 6034)
@@ -0,0 +1,56 @@
+use strict;
+use warnings;  
+
+use Test::More;
+
+use lib qw(t/lib);
+
+use DBICTest;
+use DBIC::SqlMakerTest;
+
+my $schema = DBICTest->init_schema();
+
+eval "use DBD::SQLite";
+plan skip_all => 'needs DBD::SQLite for testing' if $@;
+plan tests => 13;
+
+my $in_rs = $schema->resultset("Tag")->search({ tag => [ 'Blue', 'Shiny' ] });
+
+cmp_ok($schema->resultset("Tag")->count({ tag => 'Blue' }),
+           '==', 4, 'Count without DISTINCT');
+
+cmp_ok($schema->resultset("Tag")->count({ tag => [ 'Blue', 'Shiny' ] }, { group_by => 'tag' }),
+           '==', 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');
+
+cmp_ok($schema->resultset("Tag")->count({ tag => 'Blue' }, { distinct => 1 }),
+           '==', 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");
+
+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");
+
+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");
+
+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");
+
+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");
+
+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");
+
+cmp_ok($schema->resultset("Tag")->count({ tag => \"= 'Blue'" }),
+           '==', 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");
+
+cmp_ok($schema->resultset("Tag")->count({ tag => \" IN ('Blue', 'Shiny')" }, { group_by => [ qw/tag cd/ ] }),
+           '==', 6, "Count with literal SQL and multiple group_by");

Added: DBIx-Class/0.08/branches/count_distinct/t/count/count_joined.t
===================================================================
--- DBIx-Class/0.08/branches/count_distinct/t/count/count_joined.t	                        (rev 0)
+++ DBIx-Class/0.08/branches/count_distinct/t/count/count_joined.t	2009-04-30 07:10:36 UTC (rev 6034)
@@ -0,0 +1,15 @@
+use strict;
+use warnings;
+
+use Test::More;
+
+use lib qw(t/lib);
+
+use DBICTest;
+
+plan tests => 1;
+
+my $schema = DBICTest->init_schema();
+
+my $cds = $schema->resultset("CD")->search({ cdid => 1 }, { join => { cd_to_producer => 'producer' } });
+is($cds->count, 1, "extra joins do not explode single entity count");

Deleted: DBIx-Class/0.08/branches/count_distinct/t/count_distinct.t
===================================================================
--- DBIx-Class/0.08/branches/count_distinct/t/count_distinct.t	2009-04-30 06:53:51 UTC (rev 6033)
+++ DBIx-Class/0.08/branches/count_distinct/t/count_distinct.t	2009-04-30 07:10:36 UTC (rev 6034)
@@ -1,56 +0,0 @@
-use strict;
-use warnings;  
-
-use Test::More;
-
-use lib qw(t/lib);
-
-use DBICTest;
-use DBIC::SqlMakerTest;
-
-my $schema = DBICTest->init_schema();
-
-eval "use DBD::SQLite";
-plan skip_all => 'needs DBD::SQLite for testing' if $@;
-plan tests => 13;
-
-my $in_rs = $schema->resultset("Tag")->search({ tag => [ 'Blue', 'Shiny' ] });
-
-cmp_ok($schema->resultset("Tag")->count({ tag => 'Blue' }),
-           '==', 4, 'Count without DISTINCT');
-
-cmp_ok($schema->resultset("Tag")->count({ tag => [ 'Blue', 'Shiny' ] }, { group_by => 'tag' }),
-           '==', 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');
-
-cmp_ok($schema->resultset("Tag")->count({ tag => 'Blue' }, { distinct => 1 }),
-           '==', 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");
-
-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");
-
-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");
-
-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");
-
-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");
-
-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");
-
-cmp_ok($schema->resultset("Tag")->count({ tag => \"= 'Blue'" }),
-           '==', 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");
-
-cmp_ok($schema->resultset("Tag")->count({ tag => \" IN ('Blue', 'Shiny')" }, { group_by => [ qw/tag cd/ ] }),
-           '==', 6, "Count with literal SQL and multiple group_by");




More information about the Bast-commits mailing list