8 my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MSSQL_ODBC_${_}" } qw/DSN USER PASS/};
10 plan skip_all => 'Set $ENV{DBICTEST_MSSQL_ODBC_DSN}, _USER and _PASS to run this test'
11 unless ($dsn && $user);
15 my $schema = DBICTest::Schema->connect($dsn, $user, $pass, {AutoCommit => 1});
17 $schema->storage->ensure_connected;
19 isa_ok( $schema->storage, 'DBIx::Class::Storage::DBI::ODBC::Microsoft_SQL_Server' );
21 $schema->storage->dbh_do (sub {
22 my ($storage, $dbh) = @_;
23 eval { $dbh->do("DROP TABLE artist") };
27 artistid INT IDENTITY NOT NULL,
29 rank INT NOT NULL DEFAULT '13',
30 charfield CHAR(10) NULL,
40 # fresh $schema so we start unconnected
41 $schema = DBICTest::Schema->connect($dsn, $user, $pass, {AutoCommit => 1});
43 # test primary key handling
44 my $new = $schema->resultset('Artist')->create({ name => 'foo' });
45 ok($new->artistid > 0, "Auto-PK worked");
47 $seen_id{$new->artistid}++;
51 $new = $schema->resultset('Artist')->create({ name => 'Artist ' . $_ });
52 is ( $seen_id{$new->artistid}, undef, "id for Artist $_ is unique" );
53 $seen_id{$new->artistid}++;
56 my $it = $schema->resultset('Artist')->search( {}, {
58 order_by => 'artistid',
61 is( $it->count, 3, "LIMIT count ok" );
62 is( $it->next->name, "foo", "iterator->next ok" );
64 is( $it->next->name, "Artist 2", "iterator->next ok" );
65 is( $it->next, undef, "next past end of resultset ok" );
70 my $dbh = eval { $schema->storage->_dbh };
71 $dbh->do('DROP TABLE artist') if $dbh;