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;
18 isa_ok( $schema->storage, 'DBIx::Class::Storage::DBI::ODBC::Microsoft_SQL_Server' );
20 $schema->storage->dbh_do (sub {
21 my ($storage, $dbh) = @_;
22 eval { $dbh->do("DROP TABLE artist") };
26 artistid INT IDENTITY NOT NULL,
28 rank INT NOT NULL DEFAULT '13',
29 charfield CHAR(10) NULL,
39 # fresh $schema so we start unconnected
40 $schema = DBICTest::Schema->connect($dsn, $user, $pass, {AutoCommit => 1});
42 # test primary key handling
43 my $new = $schema->resultset('Artist')->create({ name => 'foo' });
44 ok($new->artistid > 0, "Auto-PK worked");
46 $seen_id{$new->artistid}++;
50 $new = $schema->resultset('Artist')->create({ name => 'Artist ' . $_ });
51 is ( $seen_id{$new->artistid}, undef, "id for Artist $_ is unique" );
52 $seen_id{$new->artistid}++;
55 my $it = $schema->resultset('Artist')->search( {}, {
57 order_by => 'artistid',
60 is( $it->count, 3, "LIMIT count ok" );
61 is( $it->next->name, "foo", "iterator->next ok" );
63 is( $it->next->name, "Artist 2", "iterator->next ok" );
64 is( $it->next, undef, "next past end of resultset ok" );
69 my $dbh = eval { $schema->storage->_dbh };
70 $dbh->do('DROP TABLE artist') if $dbh;