Unverified Commit 3e83aa78 authored by Katherine Walker's avatar Katherine Walker Committed by GitHub

PHPLIB-297 Support maxTimeMS option for DropIndexes operation (#434)

* PHPLIB-297 Support maxTimeMS option for DropIndexes operation
parent 1af82a40
source:
file: apiargs-common-option.yaml
ref: maxTimeMS
---
source: source:
file: apiargs-MongoDBCollection-common-option.yaml file: apiargs-MongoDBCollection-common-option.yaml
ref: typeMap ref: typeMap
......
source:
file: apiargs-common-option.yaml
ref: maxTimeMS
---
source: source:
file: apiargs-MongoDBCollection-common-option.yaml file: apiargs-MongoDBCollection-common-option.yaml
ref: typeMap ref: typeMap
......
...@@ -45,6 +45,9 @@ class DropIndexes implements Executable ...@@ -45,6 +45,9 @@ class DropIndexes implements Executable
* *
* Supported options: * Supported options:
* *
* * maxTimeMS (integer): The maximum amount of time to allow the query to
* run.
*
* * typeMap (array): Type map for BSON deserialization. This will be used * * typeMap (array): Type map for BSON deserialization. This will be used
* for the returned command result document. * for the returned command result document.
* *
...@@ -67,6 +70,10 @@ class DropIndexes implements Executable ...@@ -67,6 +70,10 @@ class DropIndexes implements Executable
throw new InvalidArgumentException('$indexName cannot be empty'); throw new InvalidArgumentException('$indexName cannot be empty');
} }
if (isset($options['maxTimeMS']) && ! is_integer($options['maxTimeMS'])) {
throw InvalidArgumentException::invalidType('"maxTimeMS" option', $options['maxTimeMS'], 'integer');
}
if (isset($options['typeMap']) && ! is_array($options['typeMap'])) { if (isset($options['typeMap']) && ! is_array($options['typeMap'])) {
throw InvalidArgumentException::invalidType('"typeMap" option', $options['typeMap'], 'array'); throw InvalidArgumentException::invalidType('"typeMap" option', $options['typeMap'], 'array');
} }
...@@ -121,6 +128,10 @@ class DropIndexes implements Executable ...@@ -121,6 +128,10 @@ class DropIndexes implements Executable
'index' => $this->indexName, 'index' => $this->indexName,
]; ];
if (isset($this->options['maxTimeMS'])) {
$cmd['maxTimeMS'] = $this->options['maxTimeMS'];
}
if (isset($this->options['writeConcern'])) { if (isset($this->options['writeConcern'])) {
$cmd['writeConcern'] = \MongoDB\write_concern_as_document($this->options['writeConcern']); $cmd['writeConcern'] = \MongoDB\write_concern_as_document($this->options['writeConcern']);
} }
......
...@@ -27,6 +27,10 @@ class DropIndexesTest extends TestCase ...@@ -27,6 +27,10 @@ class DropIndexesTest extends TestCase
{ {
$options = []; $options = [];
foreach ($this->getInvalidIntegerValues() as $value) {
$options[][] = ['maxTimeMS' => $value];
}
foreach ($this->getInvalidArrayValues() as $value) { foreach ($this->getInvalidArrayValues() as $value) {
$options[][] = ['typeMap' => $value]; $options[][] = ['typeMap' => $value];
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment