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;
15 my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MSSQL_${_}" } qw/DSN USER PASS/};
17 plan skip_all => 'Set $ENV{DBICTEST_MSSQL_DSN}, _USER and _PASS to run this test'
22 my $schema = DBICTest::Schema->clone;
23 $schema->connection($dsn, $user, $pass);
25 my $dbh = $schema->storage->dbh;
27 isa_ok($schema->storage, 'DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server');
29 $dbh->do("IF OBJECT_ID('artist', 'U') IS NOT NULL
31 $dbh->do("IF OBJECT_ID('cd', 'U') IS NOT NULL
34 $dbh->do("CREATE TABLE artist (artistid INT IDENTITY PRIMARY KEY, name VARCHAR(100), rank INT DEFAULT '13', charfield CHAR(10) NULL);");
35 $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);");
36 # Just to test compat shim, Auto is in Core
37 $schema->class('Artist')->load_components('PK::Auto::MSSQL');
40 my $new = $schema->resultset('Artist')->create( { name => 'foo' } );
41 ok($new->artistid, "Auto-PK worked");
45 $schema->resultset('Artist')->create( { name => 'Artist ' . $_, rank => $_ } );
48 my $it = $schema->resultset('Artist')->search( { },
51 order_by => 'artistid'
55 # Test ? in data don't get treated as placeholders
56 my $cd = $schema->resultset('CD')->create( {
58 title => 'Does this break things?',
61 ok($cd->id, 'Not treating ? in data as placeholders');
63 is( $it->count, 3, "LIMIT count ok" );
64 ok( $it->next->name, "iterator->next ok" );
67 is( $it->next, undef, "next past end of resultset ok" );
71 $dbh->do("IF OBJECT_ID('artist', 'U') IS NOT NULL DROP TABLE artist")
73 $dbh->do("IF OBJECT_ID('cd', 'U') IS NOT NULL DROP TABLE cd")