Skip to content

Commit

Permalink
Merge pull request #2781 from nowackipawel/patch-84
Browse files Browse the repository at this point in the history
#2780 - LIMIT.
  • Loading branch information
lonnieezell committed Apr 20, 2020
2 parents b3aeba5 + a88c6de commit c69ab50
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions system/Database/BaseBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1708,9 +1708,9 @@ public function offset(int $offset)
*
* @return string
*/
protected function _limit(string $sql): string
protected function _limit(string $sql, bool $offsetIgnore = false): string
{
return $sql . ' LIMIT ' . ($this->QBOffset ? $this->QBOffset . ', ' : '') . $this->QBLimit;
return $sql . ' LIMIT ' . (false === $offsetIgnore && $this->QBOffset ? $this->QBOffset . ', ' : '') . $this->QBLimit;
}

//--------------------------------------------------------------------
Expand Down Expand Up @@ -2476,7 +2476,7 @@ protected function _update(string $table, array $values): string
return 'UPDATE ' . $this->compileIgnore('update') . $table . ' SET ' . implode(', ', $valStr)
. $this->compileWhereHaving('QBWhere')
. $this->compileOrderBy()
. ($this->QBLimit ? $this->_limit(' ') : '');
. ($this->QBLimit ? $this->_limit(' ', true) : '');
}

//--------------------------------------------------------------------
Expand Down Expand Up @@ -2825,7 +2825,7 @@ public function delete($where = '', int $limit = null, bool $reset_data = true)
throw new DatabaseException('SQLite3 does not allow LIMITs on DELETE queries.');
}

$sql = $this->_limit($sql);
$sql = $this->_limit($sql, true);
}

if ($reset_data)
Expand Down Expand Up @@ -2887,8 +2887,7 @@ public function decrement(string $column, int $value = 1)
*/
protected function _delete(string $table): string
{
return 'DELETE ' . $this->compileIgnore('delete') . 'FROM ' . $table . $this->compileWhereHaving('QBWhere')
. ($this->QBLimit ? ' LIMIT ' . $this->QBLimit : '');
return 'DELETE ' . $this->compileIgnore('delete') . 'FROM ' . $table . $this->compileWhereHaving('QBWhere');
}

//--------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion system/Database/Postgre/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public function delete($where = '', int $limit = null, bool $reset_data = true)
*
* @return string
*/
protected function _limit(string $sql): string
protected function _limit(string $sql, bool $offsetIgnore = false): string
{
return $sql . ' LIMIT ' . $this->QBLimit . ($this->QBOffset ? " OFFSET {$this->QBOffset}" : '');
}
Expand Down

0 comments on commit c69ab50

Please sign in to comment.