Merge branch 'master' into topic/constructor_rewrite
[dbsrgits/DBIx-Class.git] / t / prefetch / o2m_o2m_order_by_with_limit.t
index c593379..bac45ad 100644 (file)
@@ -6,6 +6,12 @@ use Test::More;
 use lib qw(t/lib);
 use DBIC::SqlMakerTest;
 use DBICTest;
+use DBIx::Class::SQLMaker::LimitDialects;
+
+my ($ROWS, $OFFSET) = (
+   DBIx::Class::SQLMaker::LimitDialects->__rows_bindtype,
+   DBIx::Class::SQLMaker::LimitDialects->__offset_bindtype,
+);
 
 my $schema = DBICTest->init_schema();
 
@@ -26,7 +32,7 @@ is_same_sql_bind(
   $filtered_cd_rs->as_query,
   q{(
     SELECT  cds_unordered.cdid, cds_unordered.artist, cds_unordered.title, cds_unordered.year, cds_unordered.genreid, cds_unordered.single_track,
-            tracks.trackid, tracks.cd, tracks.position, tracks.title, tracks.last_updated_on, tracks.last_updated_at, tracks.small_dt
+            tracks.trackid, tracks.cd, tracks.position, tracks.title, tracks.last_updated_on, tracks.last_updated_at
       FROM artist me
       JOIN (
         SELECT cds_unordered.cdid, cds_unordered.artist, cds_unordered.title, cds_unordered.year, cds_unordered.genreid, cds_unordered.single_track
@@ -34,10 +40,9 @@ is_same_sql_bind(
           JOIN cd cds_unordered
             ON cds_unordered.artist = me.artistid
         WHERE ( me.rank = ? )
-        GROUP BY cds_unordered.cdid, cds_unordered.artist, cds_unordered.title, cds_unordered.year, cds_unordered.genreid, cds_unordered.single_track, me.name, me.artistid
         ORDER BY me.name ASC, me.artistid DESC
-        LIMIT 3
-        OFFSET 3
+        LIMIT ?
+        OFFSET ?
       ) cds_unordered
         ON cds_unordered.artist = me.artistid
       LEFT JOIN track tracks
@@ -45,7 +50,12 @@ is_same_sql_bind(
     WHERE ( me.rank = ? )
     ORDER BY me.name ASC, me.artistid DESC, tracks.cd
   )},
-  [ [ 'me.rank' => 13 ], [ 'me.rank' => 13 ] ],
+  [
+    [ { sqlt_datatype => 'integer', dbic_colname => 'me.rank' } => 13 ],
+    [ $ROWS => 3 ],
+    [ $OFFSET => 3 ],
+    [ { sqlt_datatype => 'integer', dbic_colname => 'me.rank' } => 13 ],
+  ],
   'correct SQL on limited prefetch over search_related ordered by root',
 );
 
@@ -71,7 +81,6 @@ is_deeply (
           'last_updated_at' => undef,
           'last_updated_on' => undef,
           'position' => '1',
-          'small_dt' => undef,
           'title' => 'Boring Name',
           'trackid' => '10'
         },
@@ -80,7 +89,6 @@ is_deeply (
           'last_updated_at' => undef,
           'last_updated_on' => undef,
           'position' => '2',
-          'small_dt' => undef,
           'title' => 'Boring Song',
           'trackid' => '11'
         },
@@ -89,7 +97,6 @@ is_deeply (
           'last_updated_at' => undef,
           'last_updated_on' => undef,
           'position' => '3',
-          'small_dt' => undef,
           'title' => 'No More Ideas',
           'trackid' => '12'
         }
@@ -108,7 +115,6 @@ is_deeply (
           'last_updated_at' => undef,
           'last_updated_on' => undef,
           'position' => '1',
-          'small_dt' => undef,
           'title' => 'Sad',
           'trackid' => '13'
         },
@@ -117,7 +123,6 @@ is_deeply (
           'last_updated_at' => undef,
           'last_updated_on' => undef,
           'position' => '3',
-          'small_dt' => undef,
           'title' => 'Suicidal',
           'trackid' => '15'
         },
@@ -126,7 +131,6 @@ is_deeply (
           'last_updated_at' => undef,
           'last_updated_on' => undef,
           'position' => '2',
-          'small_dt' => undef,
           'title' => 'Under The Weather',
           'trackid' => '14'
         }