Replicated - fixup types and namespace::clean
[dbsrgits/DBIx-Class.git] / t / 746mssql.t
index 52b5357..3e70574 100644 (file)
@@ -17,20 +17,28 @@ my $schema = DBICTest::Schema->connect($dsn, $user, $pass, {AutoCommit => 1});
 $schema->storage->ensure_connected;
 isa_ok( $schema->storage, 'DBIx::Class::Storage::DBI::ODBC::Microsoft_SQL_Server' );
 
-my $dbh = $schema->storage->dbh;
+$schema->storage->dbh_do (sub {
+    my ($storage, $dbh) = @_;
+    eval { $dbh->do("DROP TABLE artist") };
+    $dbh->do(<<'SQL');
 
-eval { $dbh->do("DROP TABLE artist") };
-
-    $dbh->do(<<'');
 CREATE TABLE artist (
    artistid INT IDENTITY NOT NULL,
-   name VARCHAR(255),
-   charfield CHAR(10),
+   name VARCHAR(100),
+   rank INT NOT NULL DEFAULT '13',
+   charfield CHAR(10) NULL,
    primary key(artistid)
 )
 
+SQL
+
+});
+
 my %seen_id;
 
+# fresh $schema so we start unconnected
+$schema = DBICTest::Schema->connect($dsn, $user, $pass, {AutoCommit => 1});
+
 # test primary key handling
 my $new = $schema->resultset('Artist')->create({ name => 'foo' });
 ok($new->artistid > 0, "Auto-PK worked");
@@ -58,6 +66,7 @@ is( $it->next, undef, "next past end of resultset ok" );
 
 # clean up our mess
 END {
+    my $dbh = eval { $schema->storage->_dbh };
     $dbh->do('DROP TABLE artist') if $dbh;
 }