4 # use this if you keep a copy of DBD::Sybase linked to FreeTDS somewhere else
6 if (my $lib_dirs = $ENV{DBICTEST_MSSQL_PERL5LIB}) {
7 unshift @INC, $_ for split /:/, $lib_dirs;
16 my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MSSQL_${_}" } qw/DSN USER PASS/};
18 plan skip_all => 'Set $ENV{DBICTEST_MSSQL_DSN}, _USER and _PASS to run this test'
23 my $schema = DBICTest::Schema->clone;
24 $schema->connection($dsn, $user, $pass);
26 # start disconnected to test reconnection
27 $schema->storage->ensure_connected;
28 $schema->storage->_dbh->disconnect;
30 isa_ok($schema->storage, 'DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server');
34 $dbh = $schema->storage->dbh;
35 }, 'reconnect works');
37 $dbh->do("IF OBJECT_ID('artist', 'U') IS NOT NULL
39 $dbh->do("IF OBJECT_ID('cd', 'U') IS NOT NULL
42 $dbh->do("CREATE TABLE artist (artistid INT IDENTITY PRIMARY KEY, name VARCHAR(100), rank INT DEFAULT '13', charfield CHAR(10) NULL);");
43 $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);");
44 # Just to test compat shim, Auto is in Core
45 $schema->class('Artist')->load_components('PK::Auto::MSSQL');
48 my $new = $schema->resultset('Artist')->create( { name => 'foo' } );
49 ok($new->artistid, "Auto-PK worked");
53 $schema->resultset('Artist')->create( { name => 'Artist ' . $_, rank => $_ } );
56 my $it = $schema->resultset('Artist')->search( { },
59 order_by => 'artistid'
63 # Test ? in data don't get treated as placeholders
64 my $cd = $schema->resultset('CD')->create( {
66 title => 'Does this break things?',
69 ok($cd->id, 'Not treating ? in data as placeholders');
71 is( $it->count, 3, "LIMIT count ok" );
72 ok( $it->next->name, "iterator->next ok" );
75 is( $it->next, undef, "next past end of resultset ok" );
79 $dbh->do("IF OBJECT_ID('artist', 'U') IS NOT NULL DROP TABLE artist")
81 $dbh->do("IF OBJECT_ID('cd', 'U') IS NOT NULL DROP TABLE cd")