mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-31 01:34:09 +02:00
DbConnection: Only ignore the *
for equal/unequal conditions
fixes #4813
This commit is contained in:
parent
253597c4fb
commit
1bee2db583
@ -6,8 +6,8 @@ namespace Icinga\Data\Db;
|
||||
use DateTime;
|
||||
use DateTimeZone;
|
||||
use Exception;
|
||||
use Icinga\Data\Filter\FilterMatch;
|
||||
use Icinga\Data\Filter\FilterMatchNot;
|
||||
use Icinga\Data\Filter\FilterEqual;
|
||||
use Icinga\Data\Filter\FilterNotEqual;
|
||||
use Icinga\Data\Inspectable;
|
||||
use Icinga\Data\Inspection;
|
||||
use PDO;
|
||||
@ -544,6 +544,9 @@ class DbConnection implements Selectable, Extensible, Updatable, Reducible, Insp
|
||||
$sign = $filter->getSign();
|
||||
$value = $filter->getExpression();
|
||||
|
||||
$matchWildcard = $sign === '=' && ! $filter instanceof FilterEqual
|
||||
|| $sign === '!=' && ! $filter instanceof FilterNotEqual;
|
||||
|
||||
if (is_array($value)) {
|
||||
$comp = [];
|
||||
$pattern = [];
|
||||
@ -579,13 +582,13 @@ class DbConnection implements Selectable, Extensible, Updatable, Reducible, Insp
|
||||
}
|
||||
|
||||
return count($sql) === 1 ? $sql[0] : '(' . implode(" $operator ", $sql) . ')';
|
||||
} elseif ($filter instanceof FilterMatch && $value !== null && strpos($value, '*') !== false) {
|
||||
} elseif ($matchWildcard && $value !== null && strpos($value, '*') !== false) {
|
||||
if ($value === '*') {
|
||||
return $column . ' IS NOT NULL';
|
||||
}
|
||||
|
||||
return $column . ' LIKE ' . $this->dbAdapter->quote(preg_replace('~\*~', '%', $value));
|
||||
} elseif ($filter instanceof FilterMatchNot && $value !== null && strpos($value, '*') !== false) {
|
||||
} elseif ($matchWildcard && $value !== null && strpos($value, '*') !== false) {
|
||||
if ($value === '*') {
|
||||
return $column . ' IS NULL';
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user