From f65f95e92582f679af47c1b68aa0a05d62d95fe6 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 3 Dec 2023 09:57:27 +0900 Subject: [PATCH] fix: limit(0) and get($limit) behavior --- system/Database/BaseBuilder.php | 8 ++++++-- system/Database/SQLSRV/Builder.php | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/system/Database/BaseBuilder.php b/system/Database/BaseBuilder.php index 065a3f503698..5dd8922fdbbd 100644 --- a/system/Database/BaseBuilder.php +++ b/system/Database/BaseBuilder.php @@ -1487,6 +1487,10 @@ public function orderBy(string $orderBy, string $direction = '', ?bool $escape = */ public function limit(?int $value = null, ?int $offset = 0) { + if (config(Feature::class)->limitZeroAsAll && $value === 0) { + $value = null; + } + if ($value !== null) { $this->QBLimit = $value; } @@ -1604,8 +1608,8 @@ protected function compileFinalQuery(string $sql): string */ public function get(?int $limit = null, int $offset = 0, bool $reset = true) { - if (config(Feature::class)->limitZeroAsAll) { - $limit ??= 0; + if (config(Feature::class)->limitZeroAsAll && $limit === 0) { + $limit = null; } if ($limit !== null) { diff --git a/system/Database/SQLSRV/Builder.php b/system/Database/SQLSRV/Builder.php index 6588438a361b..44f1f7ef13e0 100755 --- a/system/Database/SQLSRV/Builder.php +++ b/system/Database/SQLSRV/Builder.php @@ -616,6 +616,10 @@ protected function compileSelect($selectOverride = false): string */ public function get(?int $limit = null, int $offset = 0, bool $reset = true) { + if (config(Feature::class)->limitZeroAsAll && $limit === 0) { + $limit = null; + } + if ($limit !== null) { $this->limit($limit, $offset); }