Permalink
Browse files

Add missing trim() around Sqlserver queries.

This solves issues with queries failing.

Fixes #2222
  • Loading branch information...
1 parent 245c8eb commit 0f8dae55c9865fc2eeb1b2fe1d4dd66048236311 @markstory markstory committed Oct 30, 2013
Showing with 5 additions and 5 deletions.
  1. +5 −5 lib/Cake/Model/Datasource/Database/Sqlserver.php
@@ -530,19 +530,19 @@ public function renderStatement($type, $data) {
$offset = intval($limitOffset[2] * $page);
$rowCounter = self::ROW_COUNTER;
- return "
- SELECT {$limit} * FROM (
+ $sql = "SELECT {$limit} * FROM (
SELECT {$fields}, ROW_NUMBER() OVER ({$order}) AS {$rowCounter}
FROM {$table} {$alias} {$joins} {$conditions} {$group}
) AS _cake_paging_
WHERE _cake_paging_.{$rowCounter} > {$offset}
ORDER BY _cake_paging_.{$rowCounter}
";
+ return trim($sql);
}
if (strpos($limit, 'FETCH') !== false) {
- return "SELECT {$fields} FROM {$table} {$alias} {$joins} {$conditions} {$group} {$order} {$limit}";
+ return trim("SELECT {$fields} FROM {$table} {$alias} {$joins} {$conditions} {$group} {$order} {$limit}");
}
- return "SELECT {$limit} {$fields} FROM {$table} {$alias} {$joins} {$conditions} {$group} {$order}";
+ return trim("SELECT {$limit} {$fields} FROM {$table} {$alias} {$joins} {$conditions} {$group} {$order}");
case "schema":
extract($data);
@@ -558,7 +558,7 @@ public function renderStatement($type, $data) {
${$var} = "\t" . implode(",\n\t", array_filter(${$var}));
}
}
- return "CREATE TABLE {$table} (\n{$columns});\n{$indexes}";
+ return trim("CREATE TABLE {$table} (\n{$columns});\n{$indexes}");
default:
return parent::renderStatement($type, $data);
}

0 comments on commit 0f8dae5

Please sign in to comment.