MDL-25268 dml - change whitespace capture in limitfrom/limitnum regexp. Fixes some...
authorEloy Lafuente <stronk7@moodle.org>
Sat, 20 Nov 2010 00:49:01 +0000 (00:49 +0000)
committerEloy Lafuente <stronk7@moodle.org>
Sat, 20 Nov 2010 00:49:01 +0000 (00:49 +0000)
lib/dml/mssql_native_moodle_database.php
lib/dml/sqlsrv_native_moodle_database.php

index edd66f1..f1aaf11 100644 (file)
@@ -686,8 +686,8 @@ class mssql_native_moodle_database extends moodle_database {
         if ($limitfrom or $limitnum) {
             if ($limitnum >= 1) { // Only apply TOP clause if we have any limitnum (limitfrom offset is handled later)
                 $fetch = $limitfrom + $limitnum;
-                $sql = preg_replace('/^([\s(])*SELECT([\s]+)(DISTINCT|ALL)?(?!\s*TOP\s*\()/i',
-                                    "\\1SELECT\\2\\3 TOP $fetch", $sql);
+                $sql = preg_replace('/^([\s(])*SELECT([\s]+(DISTINCT|ALL))?(?!\s*TOP\s*\()/i',
+                                    "\\1SELECT\\2 TOP $fetch", $sql);
             }
         }
 
index 15b3a83..9d8ab2d 100644 (file)
@@ -778,8 +778,8 @@ class sqlsrv_native_moodle_database extends moodle_database {
         $offset = max(0, $offset);
 
         if ($limit > 0 && $offset == 0) {
-            $sql1 = preg_replace('/^([\s(])*SELECT([\s]+)(DISTINCT|ALL)?(?!\s*TOP\s*\()/i',
-                                 "\\1SELECT\\2\\3 TOP $limit", $sql);
+            $sql1 = preg_replace('/^([\s(])*SELECT([\s]+(DISTINCT|ALL))?(?!\s*TOP\s*\()/i',
+                                 "\\1SELECT\\2 TOP $limit", $sql);
         } else {
             // Only apply TOP clause if we have any limitnum (limitfrom offset is handled later)
             if ($limit < 1) {