9 my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MSSQL_ADO_${_}" } qw/DSN USER PASS/};
11 plan skip_all => 'Set $ENV{DBICTEST_MSSQL_ADO_DSN}, _USER and _PASS to run this test'
12 unless ($dsn && $user);
14 my $schema = DBICTest::Schema->connect($dsn, $user, $pass);
15 $schema->storage->ensure_connected;
17 isa_ok( $schema->storage, 'DBIx::Class::Storage::DBI::ADO::Microsoft_SQL_Server' );
19 $schema->storage->dbh_do (sub {
20 my ($storage, $dbh) = @_;
21 eval { $dbh->do("DROP TABLE artist") };
24 artistid INT IDENTITY NOT NULL,
26 rank INT NOT NULL DEFAULT '13',
27 charfield CHAR(10) NULL,
33 my $new = $schema->resultset('Artist')->create({ name => 'foo' });
34 ok($new->artistid > 0, 'Auto-PK worked');
36 # make sure select works
37 my $found = $schema->resultset('Artist')->search({ name => 'foo' })->first;
38 is $found->artistid, $new->artistid, 'search works';
40 # test large column list in select
41 $found = $schema->resultset('Artist')->search({ name => 'foo' }, {
42 select => ['artistid', 'name', map "'foo' foo_$_", 0..50],
43 as => ['artistid', 'name', map "foo_$_", 0..50],
45 is $found->artistid, $new->artistid, 'select with big column list';
46 is $found->get_column('foo_50'), 'foo', 'last item in big column list';
48 # create a few more rows
50 $schema->resultset('Artist')->create({ name => 'Artist ' . $_ });
53 # test multiple active cursors
54 my $rs1 = $schema->resultset('Artist')->search({}, { order_by => 'artistid' });
55 my $rs2 = $schema->resultset('Artist')->search({}, { order_by => 'name' });
58 ok eval { $rs2->next }, 'multiple active cursors';
61 # test bug where ADO blows up if the first bindparam is shorter than the second
62 is $schema->resultset('Artist')->search({ artistid => 2 })->first->name,
66 is $schema->resultset('Artist')->search({ artistid => 13 })->first->name,
74 if (my $dbh = eval { $schema->storage->_dbh }) {
75 eval { $dbh->do("DROP TABLE $_") }