Skip to content

Commit 80a2c92

Browse files
committed
Fix detection for mongodb community 5
1 parent 6c73f9d commit 80a2c92

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/Exception/SearchNotSupportedException.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
use MongoDB\Driver\Exception\ServerException;
66
use Throwable;
77

8+
use function preg_match;
9+
810
final class SearchNotSupportedException extends ServerException
911
{
1012
/** @internal */
@@ -34,7 +36,7 @@ public static function isSearchNotSupportedError(Throwable $e): bool
3436
// MongoDB 7-ent: Search index commands are only supported with Atlas.
3537
115 => true,
3638
// MongoDB 4 to 6, 7-community
37-
59 => 'no such command: \'createSearchIndexes\'' === $e->getMessage(),
39+
59 => (bool) preg_match('/no such command: \'(createSearchIndexes|updateSearchIndex|dropSearchIndex)\'/', $e->getMessage()),
3840
// MongoDB 4 to 6
3941
40324 => 'Unrecognized pipeline stage name: \'$listSearchIndexes\'' === $e->getMessage(),
4042
// Not an Atlas Search error

tests/Exception/SearchNotSupportedExceptionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function testListSearchIndexesNotSupportedException(): void
2424
}
2525

2626
#[DoesNotPerformAssertions]
27-
public function testCreateSearchIndexNotSupportedException(): void
27+
public function testSearchIndexManagementNotSupportedException(): void
2828
{
2929
$collection = $this->createCollection($this->getDatabaseName(), 'SearchNotSupportedException');
3030

0 commit comments

Comments
 (0)