Skip to content

Commit f65f95e

Browse files
committed
fix: limit(0) and get($limit) behavior
1 parent 942a00f commit f65f95e

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

system/Database/BaseBuilder.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,6 +1487,10 @@ public function orderBy(string $orderBy, string $direction = '', ?bool $escape =
14871487
*/
14881488
public function limit(?int $value = null, ?int $offset = 0)
14891489
{
1490+
if (config(Feature::class)->limitZeroAsAll && $value === 0) {
1491+
$value = null;
1492+
}
1493+
14901494
if ($value !== null) {
14911495
$this->QBLimit = $value;
14921496
}
@@ -1604,8 +1608,8 @@ protected function compileFinalQuery(string $sql): string
16041608
*/
16051609
public function get(?int $limit = null, int $offset = 0, bool $reset = true)
16061610
{
1607-
if (config(Feature::class)->limitZeroAsAll) {
1608-
$limit ??= 0;
1611+
if (config(Feature::class)->limitZeroAsAll && $limit === 0) {
1612+
$limit = null;
16091613
}
16101614

16111615
if ($limit !== null) {

system/Database/SQLSRV/Builder.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,10 @@ protected function compileSelect($selectOverride = false): string
616616
*/
617617
public function get(?int $limit = null, int $offset = 0, bool $reset = true)
618618
{
619+
if (config(Feature::class)->limitZeroAsAll && $limit === 0) {
620+
$limit = null;
621+
}
622+
619623
if ($limit !== null) {
620624
$this->limit($limit, $offset);
621625
}

0 commit comments

Comments
 (0)