8 my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_SYBASE_${_}" } qw/DSN USER PASS/};
10 plan skip_all => 'Set $ENV{DBICTEST_SYBASE_DSN}, _USER and _PASS to run this test'
11 unless ($dsn && $user);
15 my $schema = DBICTest::Schema->connect($dsn, $user, $pass, {AutoCommit => 1});
17 # start disconnected to test reconnection
18 $schema->storage->ensure_connected;
19 $schema->storage->_dbh->disconnect;
21 isa_ok( $schema->storage, 'DBIx::Class::Storage::DBI::Sybase' );
23 $schema->storage->dbh_do (sub {
24 my ($storage, $dbh) = @_;
25 eval { $dbh->do("DROP TABLE artist") };
29 artistid INT IDENTITY NOT NULL,
31 rank INT DEFAULT 13 NOT NULL,
32 charfield CHAR(10) NULL,
42 # fresh $schema so we start unconnected
43 $schema = DBICTest::Schema->connect($dsn, $user, $pass, {AutoCommit => 1});
45 # test primary key handling
46 my $new = $schema->resultset('Artist')->create({ name => 'foo' });
47 ok($new->artistid > 0, "Auto-PK worked");
49 $seen_id{$new->artistid}++;
53 $new = $schema->resultset('Artist')->create({ name => 'Artist ' . $_ });
54 is ( $seen_id{$new->artistid}, undef, "id for Artist $_ is unique" );
55 $seen_id{$new->artistid}++;
60 $it = $schema->resultset('Artist')->search( {}, {
62 order_by => 'artistid',
66 local $TODO = 'Sybase is very very fucked in the limit department';
68 is( $it->count, 3, "LIMIT count ok" );
71 # The iterator still works correctly with rows => 3, even though the sql is
72 # fucked, very interesting.
74 is( $it->next->name, "foo", "iterator->next ok" );
76 is( $it->next->name, "Artist 2", "iterator->next ok" );
77 is( $it->next, undef, "next past end of resultset ok" );
82 my $dbh = eval { $schema->storage->_dbh };
83 $dbh->do('DROP TABLE artist') if $dbh;