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'
18 my $schema = DBICTest::Schema->clone;
19 $schema->connection($dsn, $user, $pass);
21 my $dbh = $schema->storage->dbh;
23 isa_ok($schema->storage, 'DBIx::Class::Storage::DBI::Sybase::MSSQL');
25 $dbh->do("IF OBJECT_ID('artist', 'U') IS NOT NULL
27 $dbh->do("IF OBJECT_ID('cd', 'U') IS NOT NULL
30 $dbh->do("CREATE TABLE artist (artistid INT IDENTITY PRIMARY KEY, name VARCHAR(100), rank INT DEFAULT '13', charfield CHAR(10) NULL);");
31 $dbh->do("CREATE TABLE cd (cdid INT IDENTITY PRIMARY KEY, artist INT, title VARCHAR(100), year VARCHAR(100), genreid INT NULL, single_track INT NULL);");
32 # Just to test compat shim, Auto is in Core
33 $schema->class('Artist')->load_components('PK::Auto::MSSQL');
36 my $new = $schema->resultset('Artist')->create( { name => 'foo' } );
37 ok($new->artistid, "Auto-PK worked");
41 $schema->resultset('Artist')->create( { name => 'Artist ' . $_, rank => $_ } );
44 my $it = $schema->resultset('Artist')->search( { },
47 order_by => 'artistid'
51 # Test ? in data don't get treated as placeholders
52 my $cd = $schema->resultset('CD')->create( {
54 title => 'Does this break things?',
57 ok($cd->id, 'Not treating ? in data as placeholders');
59 is( $it->count, 3, "LIMIT count ok" );
60 ok( $it->next->name, "iterator->next ok" );
63 is( $it->next, undef, "next past end of resultset ok" );
67 $dbh->do("IF OBJECT_ID('artist', 'U') IS NOT NULL DROP TABLE artist")
69 $dbh->do("IF OBJECT_ID('cd', 'U') IS NOT NULL DROP TABLE cd")