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