Skip to content

Commit

Permalink
Use wildcard character matches only for Filter\Similar or Filter\Unli…
Browse files Browse the repository at this point in the history
…ke instances.
  • Loading branch information
raviks789 authored and nilmerg committed May 19, 2022
1 parent 0f31551 commit ec3ff5a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Compat/FilterProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,30 +63,30 @@ public static function assemblePredicate(Filter\Condition $filter)
$expression = $filter->getValue();

if (is_array($expression)) {
if ($filter instanceof Filter\UnEqual) {
if ($filter instanceof Filter\UnEqual || $filter instanceof Filter\Unlike) {
return ["($column NOT IN (?) OR $column IS NULL)" => $expression];
} elseif ($filter instanceof Filter\Equal) {
} elseif ($filter instanceof Filter\Equal || $filter instanceof Filter\Similar) {
return ["$column IN (?)" => $expression];
}

throw new InvalidArgumentException(
'Unable to render array expressions with operators other than equal or not equal'
);
} elseif (
($filter instanceof Filter\Equal || $filter instanceof Filter\Unequal)
($filter instanceof Filter\Similar || $filter instanceof Filter\Unlike)
&& strpos($expression, '*') !== false
) {
if ($expression === '*') {
return ["$column IS " . ($filter instanceof Filter\Equal ? 'NOT ' : '') . 'NULL'];
} elseif ($filter instanceof Filter\Unequal) {
return ["$column IS " . ($filter instanceof Filter\Similar ? 'NOT ' : '') . 'NULL'];
} elseif ($filter instanceof Filter\Unlike) {
return ["($column NOT LIKE ? OR $column IS NULL)" => str_replace('*', '%', $expression)];
} else {
return ["$column LIKE ?" => str_replace('*', '%', $expression)];
}
} elseif ($filter instanceof Filter\Unequal) {
} elseif ($filter instanceof Filter\Unequal || $filter instanceof Filter\Unlike) {
return ["($column != ? OR $column IS NULL)" => $expression];
} else {
if ($filter instanceof Filter\Equal) {
if ($filter instanceof Filter\Similar || $filter instanceof Filter\Equal) {
$operator = '=';
} elseif ($filter instanceof Filter\GreaterThan) {
$operator = '>';
Expand Down

0 comments on commit ec3ff5a

Please sign in to comment.