test sybase group_by count, works
[dbsrgits/DBIx-Class.git] / t / 746sybase.t
index ec5e53e..5bc5ec8 100644 (file)
@@ -11,7 +11,7 @@ my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_SYBASE_${_}" } qw/DSN USER PASS/}
 plan skip_all => 'Set $ENV{DBICTEST_SYBASE_DSN}, _USER and _PASS to run this test'
   unless ($dsn && $user);
 
-plan tests => (16 + 4*2)*2;
+plan tests => (18 + 4*2)*2;
 
 my @storage_types = (
   'DBI::Sybase',
@@ -55,13 +55,17 @@ SQL
 
   $seen_id{$new->artistid}++;
 
-# test LIMIT support
   for (1..6) {
     $new = $schema->resultset('Artist')->create({ name => 'Artist ' . $_ });
     is ( $seen_id{$new->artistid}, undef, "id for Artist $_ is unique" );
     $seen_id{$new->artistid}++;
   }
 
+# test simple count
+  is ($schema->resultset('Artist')->count, 7, 'count(*) of whole table ok');
+
+# test LIMIT support
+
 ## avoid quoting bug with NoBindVars for now
 #  my $it = $schema->resultset('Artist')->search({artistid => { '>' => 0 }}, {
 
@@ -91,6 +95,16 @@ SQL
   is( $it->next->name, "Artist 5", "iterator->next ok" );
   is( $it->next, undef, "next past end of resultset ok" );
 
+# now try a grouped count
+  $schema->resultset('Artist')->create({ name => 'Artist 6' })
+    for (1..6);
+
+  $it = $schema->resultset('Artist')->search({}, {
+    group_by => 'name'
+  });
+
+  is( $it->count, 7, 'COUNT of GROUP_BY ok' );
+
   SKIP: {
     skip 'quoting bug with NoBindVars', 4*2
         if $storage_type eq 'DBI::Sybase::NoBindVars';