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); }