plan skip_all => 'Set $ENV{DBICTEST_SYBASE_DSN}, _USER and _PASS to run this test'
unless ($dsn && $user);
-plan tests => 20*2;
+plan tests => (18 + 4*2)*2;
my @storage_types = (
'DBI::Sybase',
$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}++;
}
- my $it = $schema->resultset('Artist')->search( {}, {
+# 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 }}, {
+
+ my $it = $schema->resultset('Artist')->search({}, {
rows => 3,
order_by => 'artistid',
});
- TODO: {
- local $TODO = 'Sybase is very very fucked in the limit department';
-
- is( $it->count, 3, "LIMIT count ok" );
- }
+ is( $it->count, 3, "LIMIT count ok" );
is( $it->next->name, "foo", "iterator->next ok" );
$it->next;
is( $it->next->name, "Artist 2", "iterator->next ok" );
is( $it->next, undef, "next past end of resultset ok" );
+# now try with offset
+ $it = $schema->resultset('Artist')->search({}, {
+ rows => 3,
+ offset => 3,
+ order_by => 'artistid',
+ });
+
+ is( $it->count, 3, "LIMIT with offset count ok" );
+
+ is( $it->next->name, "Artist 3", "iterator->next ok" );
+ $it->next;
+ 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', 8
+ skip 'quoting bug with NoBindVars', 4*2
if $storage_type eq 'DBI::Sybase::NoBindVars';
# Test DateTime inflation with DATETIME