Skip to content

Commit 8dbfb0d

Browse files
* updated regex in contains if array to createSafeRegex
* updated index test
1 parent 64135d9 commit 8dbfb0d

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/Database/Adapter/Mongo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2333,7 +2333,7 @@ protected function buildFilter(Query $query): array
23332333
$filter['$or'] = array_map(function ($val) use ($attribute) {
23342334
return [
23352335
$attribute => [
2336-
'$regex' => new Regex(".*{$this->escapeWildcards($val)}.*", 'i')
2336+
'$regex' => $this->createSafeRegex($val, '.*%s.*', 'i')
23372337
]
23382338
];
23392339
}, $value);

tests/e2e/Adapter/Scopes/IndexTests.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,15 @@ public function testIndexValidation(): void
244244
'indexes' => $indexes
245245
]);
246246

247+
// not using $indexes[0] as the index validator skips indexes with same id
248+
$newIndex = new Document([
249+
'$id' => ID::custom('newIndex1'),
250+
'type' => Database::INDEX_FULLTEXT,
251+
'attributes' => ['title1', 'integer'],
252+
'lengths' => [],
253+
'orders' => [],
254+
]);
255+
247256
$validator = new Index(
248257
$attributes,
249258
$indexes,
@@ -258,7 +267,7 @@ public function testIndexValidation(): void
258267
$database->getAdapter()->getSupportForIdenticalIndexes()
259268
);
260269

261-
$this->assertFalse($validator->isValid($indexes[0]));
270+
$this->assertFalse($validator->isValid($newIndex));
262271

263272
if ($database->getAdapter()->getSupportForAttributes()) {
264273
$this->assertEquals('Attribute "integer" cannot be part of a fulltext index, must be of type string', $validator->getDescription());

0 commit comments

Comments
 (0)