mirror of
https://github.com/grocy/grocy.git
synced 2025-08-15 10:14:39 +00:00
Fixed API equals/not equals filter comparison (fixes #1182)
This commit is contained in:
@@ -93,17 +93,18 @@ class BaseApiController extends BaseController
|
|||||||
throw new \Exception('Invalid query');
|
throw new \Exception('Invalid query');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$sqlOrNull = '';
|
||||||
if (strtolower($matches['value']) == 'null')
|
if (strtolower($matches['value']) == 'null')
|
||||||
{
|
{
|
||||||
$matches['value'] = '';
|
$sqlOrNull = ' OR ' . $matches['field'] . ' IS NULL';
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($matches['op']) {
|
switch ($matches['op']) {
|
||||||
case '=':
|
case '=':
|
||||||
$data = $data->where('IFNULL(' . $matches['field'] . ', \'\') = ?', $matches['value']);
|
$data = $data->where($matches['field'] . ' = ?' . $sqlOrNull, $matches['value']);
|
||||||
break;
|
break;
|
||||||
case '!=':
|
case '!=':
|
||||||
$data = $data->where('IFNULL(' . $matches['field'] . ', \'\') != ?', $matches['value']);
|
$data = $data->where($matches['field'] . ' != ?' . $sqlOrNull, $matches['value']);
|
||||||
break;
|
break;
|
||||||
case '~':
|
case '~':
|
||||||
$data = $data->where($matches['field'] . ' LIKE ?', '%' . $matches['value'] . '%');
|
$data = $data->where($matches['field'] . ' LIKE ?', '%' . $matches['value'] . '%');
|
||||||
|
Reference in New Issue
Block a user