Merge 'trunk' into 'sybase'
[dbsrgits/DBIx-Class.git] / t / 746mssql.t
index f9cbf85..4cd1c6a 100644 (file)
@@ -54,13 +54,24 @@ my $new;
 
 # test Auto-PK with different options
 for my $opts (@opts) {
-  $schema = DBICTest::Schema->clone;
-  $schema->connection($dsn, $user, $pass, $opts);
+  SKIP: {
+    $schema = DBICTest::Schema->connect($dsn, $user, $pass, $opts);
 
-  $schema->resultset('Artist')->search({ name => 'foo' })->delete;
+    eval {
+      $schema->storage->ensure_connected
+    };
+    if ($@ =~ /dynamic cursors/) {
+      skip
+'Dynamic Cursors not functional, tds_version 8.0 or greater required if using'.
+' FreeTDS', 1;
+    }
 
-  $new = $schema->resultset('Artist')->create({ name => 'foo' });
-  ok($new->artistid > 0, "Auto-PK worked");
+    $schema->resultset('Artist')->search({ name => 'foo' })->delete;
+
+    $new = $schema->resultset('Artist')->create({ name => 'foo' });
+
+    ok($new->artistid > 0, "Auto-PK worked");
+  }
 }
 
 $seen_id{$new->artistid}++;
@@ -100,6 +111,9 @@ CREATE TABLE artist (
 SQL
 });
 
+# start disconnected to make sure insert works on an un-reblessed storage
+$schema = DBICTest::Schema->connect($dsn, $user, $pass);
+
 my $row;
 lives_ok {
   $row = $schema->resultset('ArtistGUID')->create({ name => 'mtfnpy' })
@@ -131,14 +145,11 @@ $schema->storage->dbh_do (sub {
     my ($storage, $dbh) = @_;
     eval { $dbh->do("DROP TABLE money_test") };
     $dbh->do(<<'SQL');
-
 CREATE TABLE money_test (
    id INT IDENTITY PRIMARY KEY,
    amount MONEY NULL
 )
-
 SQL
-
 });
 
 my $rs = $schema->resultset('Money');