Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2780 - LIMIT. #2781

Merged
merged 3 commits into from
Apr 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions system/Database/BaseBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1706,9 +1706,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 @@ -2469,7 +2469,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 @@ -2811,7 +2811,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 @@ -2873,8 +2873,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 @@ -269,7 +269,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