Skip to content

Commit 95215ed

Browse files
authored
Merge pull request #70 from Lukazar/bug-69-in-query
[BUG-69] fixed in clause filter
2 parents e01ff3e + 0261ef4 commit 95215ed

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/Filters/QueryMatchFilter.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function filter($collection): array
5656
$comparisonValue = preg_replace('/^[\'"]/', '', $comparisonValue);
5757
$comparisonValue = preg_replace('/[\'"]$/', '', $comparisonValue);
5858
$comparisonValue = preg_replace('/[\'"],[ ]*[\'"]/', ',', $comparisonValue);
59-
$comparisonValue = explode(",", $comparisonValue);
59+
$comparisonValue = array_map('trim', explode(",", $comparisonValue));
6060
} else {
6161
$comparisonValue = preg_replace('/^[\'"]/', '', $comparisonValue);
6262
$comparisonValue = preg_replace('/[\'"]$/', '', $comparisonValue);
@@ -113,14 +113,14 @@ public function filter($collection): array
113113
$return[] = $value;
114114
}
115115

116-
if ($operator === 'in' && is_array($comparisonValue) && in_array($value1, $comparisonValue, true)) {
116+
if ($operator === 'in' && is_array($comparisonValue) && in_array($value1, $comparisonValue)) {
117117
$return[] = $value;
118118
}
119119

120120
if (
121121
($operator === 'nin' || $operator === '!in') &&
122122
is_array($comparisonValue) &&
123-
!in_array($value1, $comparisonValue, true)
123+
!in_array($value1, $comparisonValue)
124124
) {
125125
$return[] = $value;
126126
}

tests/QueryTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1234,7 +1234,7 @@ public function queryDataProvider(): array
12341234
'filter_expression_with_in_array_of_values',
12351235
'$[?(@.d in [2, 3])]',
12361236
'[{"d":1},{"d":2},{"d":1},{"d":3},{"d":4}]',
1237-
''
1237+
'[{"d":2},{"d":3}]'
12381238
],
12391239
[ // data set #181 - unknown consensus
12401240
'filter_expression_with_in_current_object',

0 commit comments

Comments
 (0)