8 my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MSSQL_${_}" } qw/DSN USER PASS/};
10 #warn "$dsn $user $pass";
12 plan skip_all => 'Set $ENV{DBICTEST_MSSQL_DSN}, _USER and _PASS to run this test'
17 my $storage_type = '::DBI::MSSQL';
18 $storage_type = '::DBI::Sybase::MSSQL' if $dsn =~ /^dbi:Sybase:/;
19 # Add more for others in the future when they exist (ODBC? ADO? JDBC?)
21 my $schema = DBICTest::Schema->clone;
22 $schema->storage_type($storage_type);
23 $schema->connection($dsn, $user, $pass);
25 my $dbh = $schema->storage->dbh;
27 $dbh->do("IF OBJECT_ID('artist', 'U') IS NOT NULL
30 $dbh->do("CREATE TABLE artist (artistid INT IDENTITY PRIMARY KEY, name VARCHAR(255));");
31 $dbh->do("CREATE TABLE cd (cdid INT IDENTITY PRIMARY KEY, artist INT, title VARCHAR(100), year VARCHAR(100));");
33 # Just to test compat shim, Auto is in Core
34 $schema->class('Artist')->load_components('PK::Auto::MSSQL');
37 my $new = $schema->resultset('Artist')->create( { name => 'foo' } );
38 ok($new->artistid, "Auto-PK worked");
42 $schema->resultset('Artist')->create( { name => 'Artist ' . $_ } );
45 my $it = $schema->resultset('Artist')->search( { },
48 order_by => 'artistid'
52 # Test ? in data don't get treated as placeholders
53 my $cd = $schema->resultset('CD')->create( {
55 title => 'Does this break things?',
58 ok($cd->id, 'Not treating ? in data as placeholders');
60 is( $it->count, 3, "LIMIT count ok" );
61 ok( $it->next->name, "iterator->next ok" );
64 is( $it->next, undef, "next past end of resultset ok" );
68 $dbh->do("IF OBJECT_ID('artist', 'U') IS NOT NULL DROP TABLE artist")
70 $dbh->do("IF OBJECT_ID('cd', 'U') IS NOT NULL DROP TABLE cd")