Skip to content

Commit

Permalink
handle soft delete enabeld first, force order by
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Apr 30, 2020
1 parent 1a00d45 commit 5a06e0e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions system/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -473,9 +473,13 @@ public function first()

// Some databases, like PostgreSQL, need order
// information to consistently return correct results when there is group by
if (! empty($this->QBGroupBy) && empty($builder->QBOrderBy) && ! empty($this->primaryKey))
// except when soft delete is enabled
if (empty($builder->QBOrderBy) && ! empty($this->primaryKey))
{
$builder->orderBy($this->table . '.' . $this->primaryKey, 'asc');
if (! empty($this->QBGroupBy) || $this->tempUseSoftDeletes === true)
{
$builder->orderBy($this->table . '.' . $this->primaryKey, 'asc');
}
}

$row = $builder->limit(1, 0)
Expand Down

0 comments on commit 5a06e0e

Please sign in to comment.