Half way working stuff, needs a LOT of tweaking still
[dbsrgits/DBIx-Class.git] / t / 746mssql.t
index b1871f1..2f17dde 100644 (file)
@@ -10,7 +10,7 @@ my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MSSQL_ODBC_${_}" } qw/DSN USER PA
 plan skip_all => 'Set $ENV{DBICTEST_MSSQL_ODBC_DSN}, _USER and _PASS to run this test'
   unless ($dsn && $user);
 
-plan tests => 21;
+plan tests => 19;
 
 my $schema = DBICTest::Schema->connect($dsn, $user, $pass, {AutoCommit => 1});
 
@@ -93,13 +93,11 @@ CREATE TABLE Owners (
    [name] VARCHAR(100),
 )
 
-SET IDENTITY_INSERT Owners ON
-
 SQL
 
 });
 $schema->populate ('Owners', [
-  [qw/id  [name]  /],
+  [qw/id  name  /],
   [qw/1   wiggle/],
   [qw/2   woggle/],
   [qw/3   boggle/],
@@ -149,11 +147,8 @@ $schema->populate ('BooksInLibrary', [
       rows     => 5,
     });
 
-  my $owners2 = $schema->resultset ('Owners')->search ({ id => { -in => $owners->get_column ('me.id')->as_query }});
-  for ($owners, $owners2) {
-    is ($_->all, 2, 'Prefetched grouped search returns correct number of rows');
-    is ($_->count, 2, 'Prefetched grouped search returns correct count');
-  }
+  is ($owners->all, 3, 'Prefetched grouped search returns correct number of rows');
+  is ($owners->count, 3, 'Prefetched grouped search returns correct count');
 
   # try a ->belongs_to direction (no select collapse)
   my $books = $schema->resultset ('BooksInLibrary')->search ({
@@ -162,22 +157,15 @@ $schema->populate ('BooksInLibrary', [
       prefetch => 'owner',
       distinct => 1,
       order_by => 'name',
-      page     => 2,
       rows     => 5,
     });
 
-  my $books2 = $schema->resultset ('BooksInLibrary')->search ({ id => { -in => $books->get_column ('me.id')->as_query }});
-  for ($books, $books2) {
-    is ($_->all, 1, 'Prefetched grouped search returns correct number of rows');
-    is ($_->count, 1, 'Prefetched grouped search returns correct count');
-  }
-
-  #my $result = $schema->resultset('BooksInLibrary')->search(undef, {
-        #page     => 1,
-        #rows     => 25,
-        #order_by => ['name', 'title'],
-        #prefetch => 'owner'
-     #})->first;
+
+  is ($books->page(1)->all, 1, 'Prefetched grouped search returns correct number of rows');
+  is ($books->page(1)->count, 1, 'Prefetched grouped search returns correct count');
+
+  is ($books->page(2)->all, 0, 'Prefetched grouped search returns correct number of rows');
+  is ($books->page(2)->count, 0, 'Prefetched grouped search returns correct count');
 
 }