MDL-25268 dml - change whitespace capture in limitfrom/limitnum regexp. Fixes some border cases
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user