Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
StyleCIBot committed Nov 4, 2023
1 parent 04beea7 commit 21fbd36
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/QueryDataTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -1040,19 +1040,21 @@ protected function applyFixedOrderingToQuery(string $keyName, array $orderedKeys
switch ($driverName) {
case 'mysql':
$this->query->orderByRaw("FIELD($keyName, ".$orderedKeys->implode(',').')');

return true;

case 'pgsql':
case 'oracle':
$this->query->orderByRaw(
"CASE "
'CASE '
.
$orderedKeys
->map(fn($value, $index) => "WHEN $keyName=$value THEN $index")
->map(fn ($value, $index) => "WHEN $keyName=$value THEN $index")
->implode(' ')
.
" END"
' END'
);

return true;

case 'sqlite':
Expand All @@ -1061,11 +1063,12 @@ protected function applyFixedOrderingToQuery(string $keyName, array $orderedKeys
"CASE $keyName "
.
$orderedKeys
->map(fn($value, $index) => "WHEN $value THEN $index")
->map(fn ($value, $index) => "WHEN $value THEN $index")
->implode(' ')
.
" END"
' END'
);

return true;

default:
Expand Down

0 comments on commit 21fbd36

Please sign in to comment.