Skip to content

Commit

Permalink
fix: Undefined property: Config\Feature::$limitZeroAsAll
Browse files Browse the repository at this point in the history
When Config\Feature is not updated.
  • Loading branch information
kenjis committed Feb 22, 2024
1 parent fd97e1e commit 9487526
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
3 changes: 2 additions & 1 deletion system/BaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,8 @@ public function findColumn(string $columnName)
*/
public function findAll(?int $limit = null, int $offset = 0)
{
if (config(Feature::class)->limitZeroAsAll) {
$limitZeroAsAll = config(Feature::class)->limitZeroAsAll ?? true;
if ($limitZeroAsAll) {
$limit ??= 0;
}

Expand Down
21 changes: 14 additions & 7 deletions system/Database/BaseBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1493,7 +1493,8 @@ 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) {
$limitZeroAsAll = config(Feature::class)->limitZeroAsAll ?? true;
if ($limitZeroAsAll && $value === 0) {
$value = null;
}

Expand Down Expand Up @@ -1614,7 +1615,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) {
$limitZeroAsAll = config(Feature::class)->limitZeroAsAll ?? true;
if ($limitZeroAsAll && $limit === 0) {
$limit = null;
}

Expand Down Expand Up @@ -1751,7 +1753,8 @@ public function getWhere($where = null, ?int $limit = null, ?int $offset = 0, bo
$this->where($where);
}

if (config(Feature::class)->limitZeroAsAll && $limit === 0) {
$limitZeroAsAll = config(Feature::class)->limitZeroAsAll ?? true;
if ($limitZeroAsAll && $limit === 0) {
$limit = null;
}

Expand Down Expand Up @@ -2473,7 +2476,8 @@ public function update($set = null, $where = null, ?int $limit = null): bool
$this->where($where);
}

if (config(Feature::class)->limitZeroAsAll && $limit === 0) {
$limitZeroAsAll = config(Feature::class)->limitZeroAsAll ?? true;
if ($limitZeroAsAll && $limit === 0) {
$limit = null;
}

Expand Down Expand Up @@ -2518,7 +2522,8 @@ protected function _update(string $table, array $values): string
$valStr[] = $key . ' = ' . $val;
}

if (config(Feature::class)->limitZeroAsAll) {
$limitZeroAsAll = config(Feature::class)->limitZeroAsAll ?? true;
if ($limitZeroAsAll) {
return 'UPDATE ' . $this->compileIgnore('update') . $table . ' SET ' . implode(', ', $valStr)
. $this->compileWhereHaving('QBWhere')
. $this->compileOrderBy()
Expand Down Expand Up @@ -2794,7 +2799,8 @@ public function delete($where = '', ?int $limit = null, bool $resetData = true)

$sql = $this->_delete($this->removeAlias($table));

if (config(Feature::class)->limitZeroAsAll && $limit === 0) {
$limitZeroAsAll = config(Feature::class)->limitZeroAsAll ?? true;
if ($limitZeroAsAll && $limit === 0) {
$limit = null;
}

Expand Down Expand Up @@ -3064,7 +3070,8 @@ protected function compileSelect($selectOverride = false): string
. $this->compileWhereHaving('QBHaving')
. $this->compileOrderBy();

if (config(Feature::class)->limitZeroAsAll) {
$limitZeroAsAll = config(Feature::class)->limitZeroAsAll ?? true;
if ($limitZeroAsAll) {
if ($this->QBLimit) {
$sql = $this->_limit($sql . "\n");
}
Expand Down
9 changes: 6 additions & 3 deletions system/Database/SQLSRV/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,8 @@ protected function _limit(string $sql, bool $offsetIgnore = false): string
// DatabaseException:
// [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The number of
// rows provided for a FETCH clause must be greater then zero.
if (! config(Feature::class)->limitZeroAsAll && $this->QBLimit === 0) {
$limitZeroAsAll = config(Feature::class)->limitZeroAsAll ?? true;
if (! $limitZeroAsAll && $this->QBLimit === 0) {
return "SELECT * \nFROM " . $this->_fromTables() . ' WHERE 1=0 ';
}

Expand Down Expand Up @@ -599,7 +600,8 @@ protected function compileSelect($selectOverride = false): string
. $this->compileOrderBy(); // ORDER BY

// LIMIT
if (config(Feature::class)->limitZeroAsAll) {
$limitZeroAsAll = config(Feature::class)->limitZeroAsAll ?? true;
if ($limitZeroAsAll) {
if ($this->QBLimit) {
$sql = $this->_limit($sql . "\n");
}
Expand All @@ -618,7 +620,8 @@ 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) {
$limitZeroAsAll = config(Feature::class)->limitZeroAsAll ?? true;
if ($limitZeroAsAll && $limit === 0) {
$limit = null;
}

Expand Down
3 changes: 2 additions & 1 deletion system/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ protected function doFindColumn(string $columnName)
*/
protected function doFindAll(?int $limit = null, int $offset = 0)
{
if (config(Feature::class)->limitZeroAsAll) {
$limitZeroAsAll = config(Feature::class)->limitZeroAsAll ?? true;
if ($limitZeroAsAll) {
$limit ??= 0;
}

Expand Down

0 comments on commit 9487526

Please sign in to comment.