Skip to content

Commit

Permalink
fix: limit(0) and get($limit) behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Dec 3, 2023
1 parent 942a00f commit f65f95e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 6 additions & 2 deletions system/Database/BaseBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions system/Database/SQLSRV/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit f65f95e

Please sign in to comment.