Skip to content

Commit

Permalink
Columns in the order by list must be unique
Browse files Browse the repository at this point in the history
MySql is ok with it, but SqlServer error out.
See a similar issue here: laravel/nova-issues#1621
  • Loading branch information
Javdu10 authored May 27, 2021
1 parent 593f0dd commit d948014
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Illuminate/Database/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1983,6 +1983,14 @@ public function orderBy($column, $direction = 'asc')
throw new InvalidArgumentException('Order direction must be "asc" or "desc".');
}

if (is_array($this->{$this->unions ? 'unionOrders' : 'orders'})) {
foreach ($this->{$this->unions ? 'unionOrders' : 'orders'} as $value) {
if ($value['column'] === $column) {
return $this;
}
}
}

$this->{$this->unions ? 'unionOrders' : 'orders'}[] = [
'column' => $column,
'direction' => $direction,
Expand Down

0 comments on commit d948014

Please sign in to comment.