move schema state copy to _copy_state_from
[dbsrgits/DBIx-Class.git] / t / 746mssql.t
index 620258e..0193753 100644 (file)
@@ -57,7 +57,9 @@ my %opts = (
   use_mars =>
     { opts => { on_connect_call => 'use_mars' } },
   use_dynamic_cursors =>
-    { opts => { on_connect_call => 'use_dynamic_cursors' }, required => 1 },
+    { opts => { on_connect_call => 'use_dynamic_cursors' },
+      required => $schema->storage->_using_freetds ? 0 : 1,
+    },
   use_server_cursors =>
     { opts => { on_connect_call => 'use_server_cursors' } },
   NO_OPTION =>
@@ -133,6 +135,8 @@ SQL
       is_deeply \@result, \@map, "multiple active statements in $opts_name";
 
       $artist_rs->delete;
+
+      is($artist_rs->count, 0, '$dbh still viable');
     }
 
 # Test populate
@@ -278,35 +282,6 @@ SQL
           );
         }
 
-        {
-          my $book_owner_ids = $schema->resultset ('BooksInLibrary')->search ({}, {
-            rows => 6,
-            offset => 2,
-            join => 'owner',
-            distinct => 1,
-            order_by => 'owner.name',
-            unsafe_subselect_ok => 1
-          })->get_column ('owner');
-
-          my @ids = $book_owner_ids->all;
-
-          is (@ids, 6, 'Limit works');
-
-          my $book_owners = $schema->resultset ('Owners')->search ({
-            id => { -in => $book_owner_ids->as_query }
-          });
-
-          TODO: {
-            local $TODO = "Correlated limited IN subqueries will probably never preserve order";
-
-            is_deeply (
-              [ map { $_->id } ($book_owners->all) ],
-              [ $book_owner_ids->all ],
-              "$test_type: Sort is preserved across IN subqueries",
-            );
-          }
-        }
-
         # still even with lost order of IN, we should be getting correct
         # sets
         {
@@ -382,7 +357,7 @@ SQL
           },
           {
             prefetch => 'books',
-            order_by => { -asc => \['name + ?', [ test => 'xxx' ]] }, # test bindvar propagation
+            order_by => [ { -asc => \['name + ?', [ test => 'xxx' ]] }, 'me.id' ], # test bindvar propagation
             group_by => [ map { "me.$_" } $schema->source('Owners')->columns ], # the literal order_by requires an explicit group_by
             rows     => 3,  # 8 results total
             unsafe_subselect_ok => 1,
@@ -428,7 +403,7 @@ SQL
             having => \['1 = ?', [ test => 1 ] ], #test having propagation
             prefetch => 'owner',
             rows     => 2,  # 3 results total
-            order_by => { -desc => 'me.owner' },
+            order_by => [{ -desc => 'me.owner' }, 'me.id'],
             unsafe_subselect_ok => 1,
           },
         );
@@ -536,9 +511,9 @@ SQL
       TODO: {
         my $freetds_and_dynamic_cursors = 1
           if $opts_name eq 'use_dynamic_cursors' &&
-            $schema->storage->using_freetds;
+            $schema->storage->_using_freetds;
 
-        local $TODO = 
+        local $TODO =
 'these tests fail on freetds with dynamic cursors for some reason'
           if $freetds_and_dynamic_cursors;
         local $ENV{DBIC_NULLABLE_KEY_NOWARN} = 1
@@ -580,5 +555,6 @@ END {
     eval { $dbh->do("DROP TABLE $_") }
       for qw/artist artist_guid money_test books owners/;
   }
+  undef $schema;
 }
 # vim:sw=2 sts=2