[Bast-commits] r8113 - DBIx-Class/0.08/branches/mssql_limit_regression/t

ribasushi at dev.catalyst.perl.org ribasushi at dev.catalyst.perl.org
Tue Dec 15 12:06:26 GMT 2009


Author: ribasushi
Date: 2009-12-15 12:06:26 +0000 (Tue, 15 Dec 2009)
New Revision: 8113

Modified:
   DBIx-Class/0.08/branches/mssql_limit_regression/t/746mssql.t
Log:
Extend mssql limited prefetch tests

Modified: DBIx-Class/0.08/branches/mssql_limit_regression/t/746mssql.t
===================================================================
--- DBIx-Class/0.08/branches/mssql_limit_regression/t/746mssql.t	2009-12-14 22:20:45 UTC (rev 8112)
+++ DBIx-Class/0.08/branches/mssql_limit_regression/t/746mssql.t	2009-12-15 12:06:26 UTC (rev 8113)
@@ -341,7 +341,7 @@
 {
   my $rs = $schema->resultset ('BooksInLibrary')->search (
     {
-      'owner.name' => [qw/wiggle woggle/],
+      'owner.name' => { '!=', 'woggle' },
     },
     {
       prefetch => 'owner',
@@ -349,16 +349,36 @@
     }
   );
 
-  is ($rs->all, 3, 'Correct amount of objects from right-sorted joined resultset');
-  my $limited_rs = $rs->search ({}, {rows => 3, offset => 1});
-  is ($limited_rs->count, 2, 'Correct count of limited right-sorted joined resultset');
-  is ($limited_rs->count_rs->next, 2, 'Correct count_rs of limited right-sorted joined resultset');
-  is ($limited_rs->all, 2, 'Correct amount of objects from limited right-sorted joined resultset');
+  is ($rs->all, 8, 'Correct amount of objects from right-sorted joined resultset');
+  is_deeply (
+    [map { $_->owner->name } ($rs->all) ],
+    [qw/wiggle wiggle fRUE fROOH fRIOUX fREW fISMBoC boggle /],
+    'Rows were properly ordered'
+  );
 
+  my $limited_rs = $rs->search ({}, {rows => 7, offset => 2});
+  is ($limited_rs->count, 6, 'Correct count of limited right-sorted joined resultset');
+  is ($limited_rs->count_rs->next, 6, 'Correct count_rs of limited right-sorted joined resultset');
+
+  my $queries;
+  $schema->storage->debugcb(sub { $queries++; });
+  $schema->storage->debug(1);
+
   is_deeply (
+    [map { $_->owner->name } ($limited_rs->all) ],
+    [qw/fRUE fROOH fRIOUX fREW fISMBoC boggle /],
+    'Limited rows were properly ordered'
+  );
+  is ($queries, 1, 'Only one query with prefetch');
+
+  $schema->storage->debugcb(undef);
+  $schema->storage->debug(0);
+
+
+  is_deeply (
     [map { $_->name } ($limited_rs->search_related ('owner')->all) ],
-    [qw/woggle wiggle/],    # there is 1 woggle library book and 2 wiggle books, the limit gets us one of each
-    'Rows were properly ordered'
+    [qw/fRUE fROOH fRIOUX fREW fISMBoC boggle /],
+    'Rows are still properly ordered after search_related'
   );
 }
 




More information about the Bast-commits mailing list