5 use DBIx::Class::Schema::Loader::Utils qw/warnings_exist_silent sigwarn_silencer/;
7 use File::Path 'rmtree';
8 use DBIx::Class::Schema::Loader 'make_schema_at';
12 # use this if you keep a copy of DBD::Sybase linked to FreeTDS somewhere else
14 if (my $lib_dirs = $ENV{DBICTEST_MSSQL_PERL5LIB}) {
15 unshift @INC, $_ for split /:/, $lib_dirs;
21 use dbixcsl_common_tests ();
22 use dbixcsl_test_dir '$tdir';
24 use constant EXTRA_DUMP_DIR => "$tdir/mssql_extra_dump";
26 # for extra tests cleanup
29 my ($dsns, $common_version);
31 for (qw/MSSQL MSSQL_ODBC MSSQL_ADO/) {
32 next unless $ENV{"DBICTEST_${_}_DSN"};
34 $dsns->{$_}{dsn} = $ENV{"DBICTEST_${_}_DSN"};
35 $dsns->{$_}{user} = $ENV{"DBICTEST_${_}_USER"};
36 $dsns->{$_}{password} = $ENV{"DBICTEST_${_}_PASS"};
39 my $dbh = DBI->connect (@{$dsns->{$_}}{qw/dsn user password/}, { RaiseError => 1, PrintError => 0} );
43 $dbh->selectrow_hashref('master.dbo.xp_msver ProductVersion')->{Character_Value}
46 my ($maj_srv_ver) = $srv_ver =~ /^(\d+)/;
48 if (! defined $common_version or $common_version > $maj_srv_ver ) {
49 $common_version = $maj_srv_ver;
53 plan skip_all => 'You need to set the DBICTEST_MSSQL_DSN, _USER and _PASS and/or the DBICTEST_MSSQL_ODBC_DSN, _USER and _PASS environment variables'
56 my $mssql_2008_new_data_types = {
57 date => { data_type => 'date' },
58 time => { data_type => 'time' },
59 'time(0)'=> { data_type => 'time', size => 0 },
60 'time(1)'=> { data_type => 'time', size => 1 },
61 'time(2)'=> { data_type => 'time', size => 2 },
62 'time(3)'=> { data_type => 'time', size => 3 },
63 'time(4)'=> { data_type => 'time', size => 4 },
64 'time(5)'=> { data_type => 'time', size => 5 },
65 'time(6)'=> { data_type => 'time', size => 6 },
66 'time(7)'=> { data_type => 'time' },
67 datetimeoffset => { data_type => 'datetimeoffset' },
68 'datetimeoffset(0)' => { data_type => 'datetimeoffset', size => 0 },
69 'datetimeoffset(1)' => { data_type => 'datetimeoffset', size => 1 },
70 'datetimeoffset(2)' => { data_type => 'datetimeoffset', size => 2 },
71 'datetimeoffset(3)' => { data_type => 'datetimeoffset', size => 3 },
72 'datetimeoffset(4)' => { data_type => 'datetimeoffset', size => 4 },
73 'datetimeoffset(5)' => { data_type => 'datetimeoffset', size => 5 },
74 'datetimeoffset(6)' => { data_type => 'datetimeoffset', size => 6 },
75 'datetimeoffset(7)' => { data_type => 'datetimeoffset' },
76 datetime2 => { data_type => 'datetime2' },
77 'datetime2(0)' => { data_type => 'datetime2', size => 0 },
78 'datetime2(1)' => { data_type => 'datetime2', size => 1 },
79 'datetime2(2)' => { data_type => 'datetime2', size => 2 },
80 'datetime2(3)' => { data_type => 'datetime2', size => 3 },
81 'datetime2(4)' => { data_type => 'datetime2', size => 4 },
82 'datetime2(5)' => { data_type => 'datetime2', size => 5 },
83 'datetime2(6)' => { data_type => 'datetime2', size => 6 },
84 'datetime2(7)' => { data_type => 'datetime2' },
86 hierarchyid => { data_type => 'hierarchyid' },
89 my $tester = dbixcsl_common_tests->new(
91 auto_inc_pk => 'INTEGER IDENTITY NOT NULL PRIMARY KEY',
92 default_function_def => 'DATETIME DEFAULT getdate()',
93 connect_info => [values %$dsns],
94 preserve_case_mode_is_exclusive => 1,
95 quote_char => [ qw/[ ]/ ],
96 basic_date_datatype => ($common_version >= 10) ? 'DATE' : 'SMALLDATETIME',
97 default_on_clause => 'NO ACTION',
99 # http://msdn.microsoft.com/en-us/library/ms187752.aspx
102 'int identity' => { data_type => 'integer', is_auto_increment => 1 },
103 bigint => { data_type => 'bigint' },
104 int => { data_type => 'integer' },
105 integer => { data_type => 'integer' },
106 smallint => { data_type => 'smallint' },
107 tinyint => { data_type => 'tinyint' },
108 money => { data_type => 'money' },
109 smallmoney => { data_type => 'smallmoney' },
110 bit => { data_type => 'bit' },
111 real => { data_type => 'real' },
112 'float(14)' => { data_type => 'real' },
113 'float(24)' => { data_type => 'real' },
114 'float(25)' => { data_type => 'double precision' },
115 'float(53)' => { data_type => 'double precision' },
116 float => { data_type => 'double precision' },
118 => { data_type => 'double precision' },
119 'numeric(6)' => { data_type => 'numeric', size => [6,0] },
120 'numeric(6,3)' => { data_type => 'numeric', size => [6,3] },
121 'decimal(6)' => { data_type => 'decimal', size => [6,0] },
122 'decimal(6,3)' => { data_type => 'decimal', size => [6,3] },
123 'dec(6,3)' => { data_type => 'decimal', size => [6,3] },
124 numeric => { data_type => 'numeric' },
125 decimal => { data_type => 'decimal' },
126 dec => { data_type => 'decimal' },
129 datetime => { data_type => 'datetime' },
130 # test rewriting getdate() to current_timestamp
131 'datetime default getdate()'
132 => { data_type => 'datetime', default_value => \'current_timestamp',
133 original => { default_value => \'getdate()' } },
134 smalldatetime => { data_type => 'smalldatetime' },
136 ($common_version >= 10) ? %$mssql_2008_new_data_types : (),
139 char => { data_type => 'char', size => 1 },
140 'char(2)' => { data_type => 'char', size => 2 },
141 character => { data_type => 'char', size => 1 },
142 'character(2)' => { data_type => 'char', size => 2 },
143 'varchar(2)' => { data_type => 'varchar', size => 2 },
145 nchar => { data_type => 'nchar', size => 1 },
146 'nchar(2)' => { data_type => 'nchar', size => 2 },
147 'nvarchar(2)' => { data_type => 'nvarchar', size => 2 },
150 'binary' => { data_type => 'binary', size => 1 },
151 'binary(2)' => { data_type => 'binary', size => 2 },
152 'varbinary(2)' => { data_type => 'varbinary', size => 2 },
155 'varchar(max)' => { data_type => 'text' },
156 text => { data_type => 'text' },
158 'nvarchar(max)' => { data_type => 'ntext' },
159 ntext => { data_type => 'ntext' },
161 'varbinary(max)' => { data_type => 'image' },
162 image => { data_type => 'image' },
165 timestamp => { data_type => 'timestamp', inflate_datetime => 0 },
166 rowversion => { data_type => 'rowversion' },
167 uniqueidentifier => { data_type => 'uniqueidentifier' },
168 sql_variant => { data_type => 'sql_variant' },
169 xml => { data_type => 'xml' },
174 CREATE TABLE [mssql_loader_test1.dot] (
175 id INT IDENTITY NOT NULL PRIMARY KEY,
180 CREATE TABLE mssql_loader_test3 (
181 id INT IDENTITY NOT NULL PRIMARY KEY
185 CREATE VIEW mssql_loader_test4 AS
186 SELECT * FROM mssql_loader_test3
188 # test capitalization of cols in unique constraints and rels
189 q{ SET QUOTED_IDENTIFIER ON },
190 q{ SET ANSI_NULLS ON },
192 CREATE TABLE [MSSQL_Loader_Test5] (
193 [Id] INT IDENTITY NOT NULL PRIMARY KEY,
194 [FooCol] INT NOT NULL,
195 [BarCol] INT NOT NULL,
196 UNIQUE ([FooCol], [BarCol])
200 CREATE TABLE [MSSQL_Loader_Test6] (
201 [Five_Id] INT REFERENCES [MSSQL_Loader_Test5] ([Id])
204 # 8 through 12 are used for the multi-schema tests and 13 through 16 are used for multi-db tests
206 create table mssql_loader_test17 (
207 id int identity primary key
211 create table mssql_loader_test18 (
212 id int identity primary key,
214 foreign key (seventeen_id) references mssql_loader_test17(id)
215 on delete set default on update set null
220 'CREATE TABLE mssql_loader_test3 (id INT IDENTITY NOT NULL PRIMARY KEY)',
221 'DROP VIEW mssql_loader_test4',
224 '[mssql_loader_test1.dot]',
225 'mssql_loader_test3',
226 'MSSQL_Loader_Test6',
227 'MSSQL_Loader_Test5',
228 'mssql_loader_test17',
229 'mssql_loader_test18',
231 count => 14 + 30 * 2 + 26 * 2, # extra + multi-schema + mutli-db
233 my ($monikers, $classes, $self);
234 ($schema, $monikers, $classes, $self) = @_;
236 my $connect_info = [@$self{qw/dsn user password/}];
238 # Test that the table above (with '.' in name) gets loaded correctly.
240 $schema->resultset('MssqlLoaderTest1Dot') }),
241 'got a resultset for table with dot in name');
243 ok((my $from = eval { $rs->result_source->from }),
244 'got an $rsrc->from for table with dot in name');
246 is ref($from), 'SCALAR', '->table with dot in name is a scalar ref';
248 is eval { $$from }, "[mssql_loader_test1.dot]",
249 '->table with dot in name has correct name';
251 # Test capitalization of columns and unique constraints
252 ok ((my $rsrc = $schema->resultset($monikers->{mssql_loader_test5})->result_source),
253 'got result_source');
255 if ($schema->loader->preserve_case) {
256 is_deeply [ $rsrc->columns ], [qw/Id FooCol BarCol/],
257 'column name case is preserved with case-sensitive collation';
259 my %uniqs = $rsrc->unique_constraints;
260 delete $uniqs{primary};
262 is_deeply ((values %uniqs)[0], [qw/FooCol BarCol/],
263 'column name case is preserved in unique constraint with case-sensitive collation');
266 is_deeply [ $rsrc->columns ], [qw/id foocol barcol/],
267 'column names are lowercased for case-insensitive collation';
269 my %uniqs = $rsrc->unique_constraints;
270 delete $uniqs{primary};
272 is_deeply ((values %uniqs)[0], [qw/foocol barcol/],
273 'columns in unique constraint lowercased for case-insensitive collation');
277 my $five_row = $schema->resultset($monikers->{mssql_loader_test5})->new_result({});
279 if ($schema->loader->preserve_case) {
280 $five_row->foo_col(1);
281 $five_row->bar_col(2);
284 $five_row->foocol(1);
285 $five_row->barcol(2);
289 my $six_row = $five_row->create_related('mssql_loader_test6s', {});
291 is $six_row->five->id, 1;
292 } 'relationships for mixed-case tables/columns detected';
294 # Test that a bad view (where underlying table is gone) is ignored.
295 my $dbh = $schema->storage->dbh;
296 $dbh->do("DROP TABLE mssql_loader_test3");
298 warnings_exist_silent { $schema->rescan }
299 qr/^Bad table or view 'mssql_loader_test4'/, 'bad view ignored';
302 $schema->resultset($monikers->{mssql_loader_test4})
303 } qr/Can't find source/,
304 'no source registered for bad view';
306 # test on delete/update fk clause introspection
307 ok ((my $rel_info = $schema->source('MssqlLoaderTest18')->relationship_info('seventeen')),
310 is $rel_info->{attrs}{on_delete}, 'SET DEFAULT',
311 'ON DELETE clause introspected correctly';
313 is $rel_info->{attrs}{on_update}, 'SET NULL',
314 'ON UPDATE clause introspected correctly';
316 is $rel_info->{attrs}{is_deferrable}, 1,
317 'is_deferrable defaults to 1';
320 my $dbh = $schema->storage->dbh;
323 $dbh->do('CREATE SCHEMA [dbicsl-test]');
326 skip "no CREATE SCHEMA privileges", 30 * 2;
330 CREATE TABLE [dbicsl-test].mssql_loader_test8 (
331 id INT IDENTITY PRIMARY KEY,
336 CREATE TABLE [dbicsl-test].mssql_loader_test9 (
337 id INT IDENTITY PRIMARY KEY,
339 eight_id INTEGER NOT NULL,
340 CONSTRAINT loader_test9_uniq UNIQUE (eight_id),
341 FOREIGN KEY (eight_id) REFERENCES [dbicsl-test].mssql_loader_test8 (id)
344 $dbh->do('CREATE SCHEMA [dbicsl.test]');
346 CREATE TABLE [dbicsl.test].mssql_loader_test9 (
347 pk INT IDENTITY PRIMARY KEY,
349 eight_id INTEGER NOT NULL,
350 CONSTRAINT loader_test9_uniq UNIQUE (eight_id),
351 FOREIGN KEY (eight_id) REFERENCES [dbicsl-test].mssql_loader_test8 (id)
355 CREATE TABLE [dbicsl.test].mssql_loader_test10 (
356 id INT IDENTITY PRIMARY KEY,
358 mssql_loader_test8_id INTEGER,
359 FOREIGN KEY (mssql_loader_test8_id) REFERENCES [dbicsl-test].mssql_loader_test8 (id)
363 CREATE TABLE [dbicsl.test].mssql_loader_test11 (
364 id INT IDENTITY PRIMARY KEY,
366 ten_id INTEGER NOT NULL UNIQUE,
367 FOREIGN KEY (ten_id) REFERENCES [dbicsl.test].mssql_loader_test10 (id)
371 CREATE TABLE [dbicsl-test].mssql_loader_test12 (
372 id INT IDENTITY PRIMARY KEY,
374 mssql_loader_test11_id INTEGER,
375 FOREIGN KEY (mssql_loader_test11_id) REFERENCES [dbicsl.test].mssql_loader_test11 (id)
379 my $guard = Scope::Guard->new(\&cleanup_schemas);
381 foreach my $db_schema (['dbicsl-test', 'dbicsl.test'], '%') {
383 rmtree EXTRA_DUMP_DIR;
386 local $SIG{__WARN__} = sub {
387 push @warns, $_[0] unless $_[0] =~ /\bcollides\b/;
394 db_schema => $db_schema,
395 dump_directory => EXTRA_DUMP_DIR,
401 diag join "\n", @warns if @warns;
404 } 'dumped schema for "dbicsl-test" and "dbicsl.test" schemas with no warnings';
406 my ($test_schema, $rsrc, $rs, $row, %uniqs, $rel_info);
409 ok $test_schema = MSSQLMultiSchema->connect(@$connect_info);
410 } 'connected test schema';
413 ok $rsrc = $test_schema->source('MssqlLoaderTest8');
414 } 'got source for table in schema name with dash';
416 is try { $rsrc->column_info('id')->{is_auto_increment} }, 1,
417 'column in schema name with dash';
419 is try { $rsrc->column_info('value')->{data_type} }, 'varchar',
420 'column in schema name with dash';
422 is try { $rsrc->column_info('value')->{size} }, 100,
423 'column in schema name with dash';
426 ok $rs = $test_schema->resultset('MssqlLoaderTest8');
427 } 'got resultset for table in schema name with dash';
430 ok $row = $rs->create({ value => 'foo' });
431 } 'executed SQL on table in schema name with dash';
433 $rel_info = try { $rsrc->relationship_info('dbicsl_dash_test_mssql_loader_test9') };
435 is_deeply $rel_info->{cond}, {
436 'foreign.eight_id' => 'self.id'
437 }, 'relationship in schema name with dash';
439 is $rel_info->{attrs}{accessor}, 'single',
440 'relationship in schema name with dash';
442 is $rel_info->{attrs}{join_type}, 'LEFT',
443 'relationship in schema name with dash';
446 ok $rsrc = $test_schema->source('DbicslDashTestMssqlLoaderTest9');
447 } 'got source for table in schema name with dash';
449 %uniqs = try { $rsrc->unique_constraints };
452 'got unique and primary constraint in schema name with dash';
454 delete $uniqs{primary};
456 is_deeply ((values %uniqs)[0], ['eight_id'],
457 'correct unique constraint in schema name with dash');
460 ok $rsrc = $test_schema->source('MssqlLoaderTest10');
461 } 'got source for table in schema name with dot';
463 is try { $rsrc->column_info('id')->{is_auto_increment} }, 1,
464 'column in schema name with dot introspected correctly';
466 is try { $rsrc->column_info('value')->{data_type} }, 'varchar',
467 'column in schema name with dot introspected correctly';
469 is try { $rsrc->column_info('value')->{size} }, 100,
470 'column in schema name with dot introspected correctly';
473 ok $rs = $test_schema->resultset('MssqlLoaderTest10');
474 } 'got resultset for table in schema name with dot';
477 ok $row = $rs->create({ value => 'foo' });
478 } 'executed SQL on table in schema name with dot';
480 $rel_info = try { $rsrc->relationship_info('mssql_loader_test11') };
482 is_deeply $rel_info->{cond}, {
483 'foreign.ten_id' => 'self.id'
484 }, 'relationship in schema name with dot';
486 is $rel_info->{attrs}{accessor}, 'single',
487 'relationship in schema name with dot';
489 is $rel_info->{attrs}{join_type}, 'LEFT',
490 'relationship in schema name with dot';
493 ok $rsrc = $test_schema->source('MssqlLoaderTest11');
494 } 'got source for table in schema name with dot';
496 %uniqs = try { $rsrc->unique_constraints };
499 'got unique and primary constraint in schema name with dot';
501 delete $uniqs{primary};
503 is_deeply ((values %uniqs)[0], ['ten_id'],
504 'correct unique constraint in schema name with dot');
507 ok $test_schema->source('MssqlLoaderTest10')
508 ->has_relationship('mssql_loader_test8');
509 } 'cross-schema relationship in multi-db_schema';
512 ok $test_schema->source('MssqlLoaderTest8')
513 ->has_relationship('mssql_loader_test10s');
514 } 'cross-schema relationship in multi-db_schema';
517 ok $test_schema->source('MssqlLoaderTest12')
518 ->has_relationship('mssql_loader_test11');
519 } 'cross-schema relationship in multi-db_schema';
522 ok $test_schema->source('MssqlLoaderTest11')
523 ->has_relationship('mssql_loader_test12s');
524 } 'cross-schema relationship in multi-db_schema';
530 local $SIG{__WARN__} = sigwarn_silencer(
531 qr/Changed database context/
534 my $dbh = $schema->storage->dbh;
537 $dbh->do('USE master');
538 $dbh->do('CREATE DATABASE dbicsl_test1');
541 diag "no CREATE DATABASE privileges: '$_'";
542 skip "no CREATE DATABASE privileges", 26 * 2;
545 $dbh->do('CREATE DATABASE dbicsl_test2');
547 $dbh->do('USE dbicsl_test1');
550 CREATE TABLE mssql_loader_test13 (
551 id INT IDENTITY PRIMARY KEY,
556 CREATE TABLE mssql_loader_test14 (
557 id INT IDENTITY PRIMARY KEY,
559 thirteen_id INTEGER REFERENCES mssql_loader_test13 (id),
560 CONSTRAINT loader_test14_uniq UNIQUE (thirteen_id)
564 $dbh->do('USE dbicsl_test2');
567 CREATE TABLE mssql_loader_test14 (
568 pk INT IDENTITY PRIMARY KEY,
571 CONSTRAINT loader_test14_uniq UNIQUE (thirteen_id)
576 CREATE TABLE mssql_loader_test15 (
577 id INT IDENTITY PRIMARY KEY,
582 CREATE TABLE mssql_loader_test16 (
583 id INT IDENTITY PRIMARY KEY,
585 fifteen_id INTEGER UNIQUE REFERENCES mssql_loader_test15 (id)
589 my $guard = Scope::Guard->new(\&cleanup_databases);
591 foreach my $db_schema ({ dbicsl_test1 => '%', dbicsl_test2 => '%' }, { '%' => '%' }) {
594 local $SIG{__WARN__} = sub {
595 push @warns, $_[0] unless $_[0] =~ /\bcollides\b/;
599 'MSSQLMultiDatabase',
602 db_schema => $db_schema,
603 dump_directory => EXTRA_DUMP_DIR,
609 diag join "\n", @warns if @warns;
612 } "dumped schema for databases 'dbicsl_test1' and 'dbicsl_test2' with no warnings";
617 ok $test_schema = MSSQLMultiDatabase->connect(@$connect_info);
618 } 'connected test schema';
620 my ($rsrc, $rs, $row, $rel_info, %uniqs);
623 ok $rsrc = $test_schema->source('MssqlLoaderTest13');
624 } 'got source for table in database one';
626 is try { $rsrc->column_info('id')->{is_auto_increment} }, 1,
627 'column in database one';
629 is try { $rsrc->column_info('value')->{data_type} }, 'varchar',
630 'column in database one';
632 is try { $rsrc->column_info('value')->{size} }, 100,
633 'column in database one';
636 ok $rs = $test_schema->resultset('MssqlLoaderTest13');
637 } 'got resultset for table in database one';
640 ok $row = $rs->create({ value => 'foo' });
641 } 'executed SQL on table in database one';
643 $rel_info = try { $rsrc->relationship_info('mssql_loader_test14') };
645 is_deeply $rel_info->{cond}, {
646 'foreign.thirteen_id' => 'self.id'
647 }, 'relationship in database one';
649 is $rel_info->{attrs}{accessor}, 'single',
650 'relationship in database one';
652 is $rel_info->{attrs}{join_type}, 'LEFT',
653 'relationship in database one';
656 ok $rsrc = $test_schema->source('DbicslTest1MssqlLoaderTest14');
657 } 'got source for table in database one';
659 %uniqs = try { $rsrc->unique_constraints };
662 'got unique and primary constraint in database one';
664 delete $uniqs{primary};
666 is_deeply ((values %uniqs)[0], ['thirteen_id'],
667 'correct unique constraint in database one');
670 ok $rsrc = $test_schema->source('MssqlLoaderTest15');
671 } 'got source for table in database two';
673 is try { $rsrc->column_info('id')->{is_auto_increment} }, 1,
674 'column in database two introspected correctly';
676 is try { $rsrc->column_info('value')->{data_type} }, 'varchar',
677 'column in database two introspected correctly';
679 is try { $rsrc->column_info('value')->{size} }, 100,
680 'column in database two introspected correctly';
683 ok $rs = $test_schema->resultset('MssqlLoaderTest15');
684 } 'got resultset for table in database two';
687 ok $row = $rs->create({ value => 'foo' });
688 } 'executed SQL on table in database two';
690 $rel_info = try { $rsrc->relationship_info('mssql_loader_test16') };
692 is_deeply $rel_info->{cond}, {
693 'foreign.fifteen_id' => 'self.id'
694 }, 'relationship in database two';
696 is $rel_info->{attrs}{accessor}, 'single',
697 'relationship in database two';
699 is $rel_info->{attrs}{join_type}, 'LEFT',
700 'relationship in database two';
703 ok $rsrc = $test_schema->source('MssqlLoaderTest16');
704 } 'got source for table in database two';
706 %uniqs = try { $rsrc->unique_constraints };
709 'got unique and primary constraint in database two';
711 delete $uniqs{primary};
713 is_deeply ((values %uniqs)[0], ['fifteen_id'],
714 'correct unique constraint in database two');
721 $tester->run_tests();
723 sub cleanup_schemas {
724 return if $ENV{SCHEMA_LOADER_TESTS_NOCLEANUP};
726 # switch back to default database
727 $schema->storage->disconnect;
728 my $dbh = $schema->storage->dbh;
730 foreach my $table ('[dbicsl-test].mssql_loader_test12',
731 '[dbicsl.test].mssql_loader_test11',
732 '[dbicsl.test].mssql_loader_test10',
733 '[dbicsl.test].mssql_loader_test9',
734 '[dbicsl-test].mssql_loader_test9',
735 '[dbicsl-test].mssql_loader_test8') {
737 $dbh->do("DROP TABLE $table");
740 diag "Error dropping table: $_";
744 foreach my $db_schema (qw/dbicsl-test dbicsl.test/) {
746 $dbh->do(qq{DROP SCHEMA [$db_schema]});
749 diag "Error dropping test schema $db_schema: $_";
753 rmtree EXTRA_DUMP_DIR;
756 sub cleanup_databases {
757 return if $ENV{SCHEMA_LOADER_TESTS_NOCLEANUP};
760 local $SIG{__WARN__} = sigwarn_silencer(
761 qr/Changed database context/
764 my $dbh = $schema->storage->dbh;
766 $dbh->do('USE dbicsl_test1');
768 foreach my $table ('mssql_loader_test14',
769 'mssql_loader_test13') {
771 $dbh->do("DROP TABLE $table");
774 diag "Error dropping table: $_";
778 $dbh->do('USE dbicsl_test2');
780 foreach my $table ('mssql_loader_test16',
781 'mssql_loader_test15',
782 'mssql_loader_test14') {
784 $dbh->do("DROP TABLE $table");
787 diag "Error dropping table: $_";
791 $dbh->do('USE master');
793 foreach my $database (qw/dbicsl_test1 dbicsl_test2/) {
795 $dbh->do(qq{DROP DATABASE $database});
798 diag "Error dropping test database '$database': $_";
802 rmtree EXTRA_DUMP_DIR;
804 # vim:et sts=4 sw=4 tw=0: