rename occurences of belongs_to in tests
[dbsrgits/DBIx-Class.git] / t / prefetch / o2m_o2m_order_by_with_limit.t
index f7f71e5..de2e734 100644 (file)
@@ -22,8 +22,8 @@ my $filtered_cd_rs = $artist_rs->search_related('cds_unordered',
   { "$ar.rank" => 13 },
   {
     prefetch => [ 'tracks' ],
-    order_by => [ 'tracks.position DESC', { -asc => "$ar.name" }, "$ar.artistid DESC" ],
-    offset   => 13,
+    order_by => [ { -asc => "$ar.name" }, "$ar.artistid DESC" ],
+    offset   => 3,
     rows     => 3,
   },
 );
@@ -39,10 +39,8 @@ is_same_sql_bind(
           FROM artist me
           JOIN cd cds_unordered
             ON cds_unordered.artist = me.artistid
-          LEFT JOIN track tracks
-            ON tracks.cd = cds_unordered.cdid
         WHERE ( me.rank = ? )
-        ORDER BY tracks.position DESC, me.name ASC, me.artistid DESC
+        ORDER BY me.name ASC, me.artistid DESC
         LIMIT ?
         OFFSET ?
       ) cds_unordered
@@ -50,12 +48,12 @@ is_same_sql_bind(
       LEFT JOIN track tracks
         ON tracks.cd = cds_unordered.cdid
     WHERE ( me.rank = ? )
-    ORDER BY tracks.position DESC, me.name ASC, me.artistid DESC
+    ORDER BY me.name ASC, me.artistid DESC, tracks.cd
   )},
   [
     [ { sqlt_datatype => 'integer', dbic_colname => 'me.rank' } => 13 ],
     [ $ROWS => 3 ],
-    [ $OFFSET => 13 ],
+    [ $OFFSET => 3 ],
     [ { sqlt_datatype => 'integer', dbic_colname => 'me.rank' } => 13 ],
   ],
   'correct SQL on limited prefetch over search_related ordered by root',
@@ -63,10 +61,10 @@ is_same_sql_bind(
 
 # note: we only requested "get all cds of all artists with rank 13 then order
 # by the artist name and give me the fourth, fifth and sixth", consequently the
-# cds that belong to the same artist are unordered; fortunately we know that
+# cds that refer to the same artist are unordered; fortunately we know that
 # the first artist have 3 cds and the second and third artist both have only
-# one, so the first 3 cds belong to the first artist and the fourth and fifth
-# cds belong to the second and third artist, respectively, and there's no sixth
+# one, so the first 3 cds refer to the first artist and the fourth and fifth
+# cds refer to the second and third artist, respectively, and there's no sixth
 # row
 is_deeply (
   $filtered_cd_rs->all_hri,
@@ -82,9 +80,9 @@ is_deeply (
           'cd' => '4',
           'last_updated_at' => undef,
           'last_updated_on' => undef,
-          'position' => '3',
-          'title' => 'No More Ideas',
-          'trackid' => '12'
+          'position' => '1',
+          'title' => 'Boring Name',
+          'trackid' => '10'
         },
         {
           'cd' => '4',
@@ -98,9 +96,9 @@ is_deeply (
           'cd' => '4',
           'last_updated_at' => undef,
           'last_updated_on' => undef,
-          'position' => '1',
-          'title' => 'Boring Name',
-          'trackid' => '10'
+          'position' => '3',
+          'title' => 'No More Ideas',
+          'trackid' => '12'
         }
       ],
       'year' => '2001'
@@ -116,6 +114,14 @@ is_deeply (
           'cd' => '5',
           'last_updated_at' => undef,
           'last_updated_on' => undef,
+          'position' => '1',
+          'title' => 'Sad',
+          'trackid' => '13'
+        },
+        {
+          'cd' => '5',
+          'last_updated_at' => undef,
+          'last_updated_on' => undef,
           'position' => '3',
           'title' => 'Suicidal',
           'trackid' => '15'
@@ -127,14 +133,6 @@ is_deeply (
           'position' => '2',
           'title' => 'Under The Weather',
           'trackid' => '14'
-        },
-        {
-          'cd' => '5',
-          'last_updated_at' => undef,
-          'last_updated_on' => undef,
-          'position' => '1',
-          'title' => 'Sad',
-          'trackid' => '13'
         }
       ],
       'year' => '1998'