Parameterize pagination
[dbsrgits/DBIx-Class.git] / t / count / count_rs.t
index af0f036..7ed4cb5 100644 (file)
@@ -7,6 +7,12 @@ use Test::More;
 use DBICTest;
 use DBIC::SqlMakerTest;
 use DBIC::DebugObj;
+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();
 
@@ -51,7 +57,7 @@ my $schema = DBICTest->init_schema();
           JOIN track tracks ON tracks.cd = me.cdid
           JOIN cd disc ON disc.cdid = tracks.cd
         WHERE ( ( position = ? OR position = ? ) )
-        LIMIT 3 OFFSET 8
+        LIMIT ? OFFSET ?
        ) tracks
     )',
     [
@@ -59,6 +65,8 @@ my $schema = DBICTest->init_schema();
         => 1 ],
       [ { sqlt_datatype => 'int', dbic_colname => 'position' }
         => 2 ],
+      [$ROWS => 3],
+      [$OFFSET => 8],
     ],
     'count_rs db-side limit applied',
   );
@@ -111,7 +119,7 @@ my $schema = DBICTest->init_schema();
           JOIN artist artist ON artist.artistid = cds.artist
         WHERE tracks.position = ? OR tracks.position = ?
         GROUP BY cds.cdid
-        LIMIT 3 OFFSET 4
+        LIMIT ? OFFSET ?
       ) cds
     )',
     [
@@ -119,12 +127,14 @@ my $schema = DBICTest->init_schema();
         => 1 ],
       [ { sqlt_datatype => 'int', dbic_colname => 'tracks.position' }
         => 2 ],
+      [ $ROWS => 3],
+      [$OFFSET => 4],
     ],
     'count_rs db-side limit applied',
   );
 }
 
-# count with a having clause 
+# count with a having clause
 {
   my $rs = $schema->resultset("Artist")->search(
     {},
@@ -144,9 +154,9 @@ my $schema = DBICTest->init_schema();
     '(SELECT COUNT( * )
       FROM (
         SELECT me.artistid, MAX( cds.year ) AS newest_cd_year,
-          FROM artist me 
-          LEFT JOIN cd cds ON cds.artist = me.artistid 
-        GROUP BY me.artistid 
+          FROM artist me
+          LEFT JOIN cd cds ON cds.artist = me.artistid
+        GROUP BY me.artistid
         HAVING newest_cd_year = ?
       ) me
     )',