From 3d2a732cd343d65b4fee47e028389fb45a302371 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Tue, 21 Jun 2011 15:30:17 -0430 Subject: [PATCH] Reverting testing changes pushed in past commit --- lib/Cake/Model/Datasource/Database/Sqlserver.php | 15 ++++++++++++++- .../Case/Console/Command/Task/ProjectTaskTest.php | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Model/Datasource/Database/Sqlserver.php b/lib/Cake/Model/Datasource/Database/Sqlserver.php index 3f7e7ae08..71ebd21bb 100644 --- a/lib/Cake/Model/Datasource/Database/Sqlserver.php +++ b/lib/Cake/Model/Datasource/Database/Sqlserver.php @@ -517,7 +517,20 @@ class Sqlserver extends DboSource { $offset = intval($offset[1]) + intval($limitVal[1]); $rOrder = $this->__switchSort($order); list($order2, $rOrder) = array($this->__mapFields($order), $this->__mapFields($rOrder)); - return "SELECT * FROM (SELECT {$limit} * FROM (SELECT TOP {$offset} {$fields} FROM {$table} {$alias} {$joins} {$conditions} {$group} {$order}) AS Set1 {$rOrder}) AS Set2 {$order2}"; + $limit2 = str_replace('TOP', '', $limit); + if (!$order) { + $order = 'ORDER BY (SELECT NULL)'; + } + + $pagination = " + SELECT {$limit} * FROM ( + SELECT {$fields}, ROW_NUMBER() OVER ({$order}) AS ssma\$rownum + FROM {$table} {$alias} {$joins} {$conditions} {$group} + ) AS ssma\$sub1 + WHERE ssma\$sub1.[ssma\$rownum] > {$limit2} + ORDER BY ssma\$sub1.[ssma\$rownum] + "; + return $pagination; } else { return "SELECT {$limit} {$fields} FROM {$table} {$alias} {$joins} {$conditions} {$group} {$order}"; } diff --git a/lib/Cake/Test/Case/Console/Command/Task/ProjectTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/ProjectTaskTest.php index c4e73cf34..fc7714f2e 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/ProjectTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/ProjectTaskTest.php @@ -245,7 +245,7 @@ class ProjectTaskTest extends CakeTestCase { $this->assertTrue($result); $this->assertEqual(Configure::read('Routing.prefixes'), array('my_prefix')); - @$file->delete(); + $file->delete(); } /**