Correct the + symbol processing when sorting results in the API controllers (#1322)
This commit is contained in:
parent
c7371090ba
commit
7343389f7b
1 changed files with 4 additions and 3 deletions
|
@ -216,15 +216,16 @@ class Api {
|
||||||
{
|
{
|
||||||
$api_field = substr($sort_token, 1);
|
$api_field = substr($sort_token, 1);
|
||||||
|
|
||||||
$db_field = $this->model->db_field($api_field);
|
|
||||||
|
|
||||||
$direction_operator = substr($sort_token, 0, 1);
|
$direction_operator = substr($sort_token, 0, 1);
|
||||||
|
|
||||||
if ( ! in_array($direction_operator, ['-', '+']))
|
if ( ! in_array($direction_operator, ['-', '+']))
|
||||||
{
|
{
|
||||||
throw new InvalidArgumentException('Invalid sort direction operator provided (expected "-" or "+"): ' . $direction_operator);
|
$direction_operator = '+';
|
||||||
|
$api_field = $sort_token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$db_field = $this->model->db_field($api_field);
|
||||||
|
|
||||||
$direction = $direction_operator === '-' ? 'DESC' : 'ASC';
|
$direction = $direction_operator === '-' ? 'DESC' : 'ASC';
|
||||||
|
|
||||||
$order_by[] = $db_field . ' ' . $direction;
|
$order_by[] = $db_field . ' ' . $direction;
|
||||||
|
|
Loading…
Reference in a new issue