Skip to content

Commit

Permalink
Add management of 'NIN' comparison operator
Browse files Browse the repository at this point in the history
  • Loading branch information
botisSmile committed Feb 14, 2025
1 parent df8e6ae commit 02b3815
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Search/ExpressionVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public function walkComparison(Comparison $comparison, bool $isStitchedQuery = f
[$type, $field, $comeFromFacet] = $this->explodeFieldTypeName($comparison->getField());
$value = $this->dispatch($comparison->getValue(), $isStitchedQuery);
$operator = $this->getGallyOperator($comparison->getOperator());
$hasNegation = str_starts_with($comparison->getOperator(), 'NOT') || '<>' === $comparison->getOperator();
$hasNegation = str_starts_with($comparison->getOperator(), 'NOT') || \in_array($comparison->getOperator(), ['<>', 'NIN'], true);

if ('all_text' === $field) {
$this->searchQuery = $value;
Expand Down Expand Up @@ -281,7 +281,7 @@ private function explodeFieldTypeName(string $field): array
private function getGallyOperator(string $operator): string
{
return match ($operator) {
'IN', 'NOT IN' => Request::FILTER_OPERATOR_IN,
'IN', 'NOT IN', 'NIN' => Request::FILTER_OPERATOR_IN,
'LIKE', 'NOT LIKE' => Request::FILTER_OPERATOR_MATCH,
'EXISTS', 'NOT EXISTS' => Request::FILTER_OPERATOR_EXISTS,
'>' => Request::FILTER_OPERATOR_GT,
Expand Down
8 changes: 8 additions & 0 deletions src/Tests/Search/ExpressionVisitorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ protected function dispatchTestDataProvider(): iterable
],
],
];
yield [
new Comparison('type', 'NIN', new Value(['configurable', 'kit'])),
[
'queryFilters' => [
['boolFilter' => ['_not' => [['equalFilter' => ['field' => 'type', 'in' => ['configurable', 'kit']]]]]],
],
],
];
yield [
new Comparison('sku', '=', new Value('test')),
[
Expand Down

0 comments on commit 02b3815

Please sign in to comment.