PHPLIB-500: Support for allowDiskUse on find operations

parent 68d49083
...@@ -47,6 +47,17 @@ operation: ~ ...@@ -47,6 +47,17 @@ operation: ~
optional: true optional: true
--- ---
arg_name: option arg_name: option
name: allowDiskUse
type: boolean
description: |
Enables writing to temporary files. When set to ``true``, queries can write
data to the ``_tmp`` sub-directory in the ``dbPath`` directory. The default is
``false``.
interface: phpmethod
operation: ~
optional: true
---
arg_name: option
name: batchSize name: batchSize
type: integer type: integer
description: | description: |
......
...@@ -10,6 +10,10 @@ source: ...@@ -10,6 +10,10 @@ source:
file: apiargs-MongoDBCollection-method-find-option.yaml file: apiargs-MongoDBCollection-method-find-option.yaml
ref: skip ref: skip
--- ---
source:
file: apiargs-MongoDBCollection-method-find-option.yaml
ref: allowDiskUse
---
source: source:
file: apiargs-MongoDBCollection-common-option.yaml file: apiargs-MongoDBCollection-common-option.yaml
ref: collation ref: collation
......
...@@ -14,6 +14,10 @@ source: ...@@ -14,6 +14,10 @@ source:
file: apiargs-MongoDBCollection-method-find-option.yaml file: apiargs-MongoDBCollection-method-find-option.yaml
ref: limit ref: limit
--- ---
source:
file: apiargs-MongoDBCollection-method-find-option.yaml
ref: allowDiskUse
---
source: source:
file: apiargs-MongoDBCollection-method-find-option.yaml file: apiargs-MongoDBCollection-method-find-option.yaml
ref: batchSize ref: batchSize
......
...@@ -10,6 +10,10 @@ source: ...@@ -10,6 +10,10 @@ source:
file: apiargs-MongoDBCollection-method-find-option.yaml file: apiargs-MongoDBCollection-method-find-option.yaml
ref: skip ref: skip
--- ---
source:
file: apiargs-MongoDBCollection-method-find-option.yaml
ref: allowDiskUse
---
source: source:
file: apiargs-MongoDBCollection-common-option.yaml file: apiargs-MongoDBCollection-common-option.yaml
ref: collation ref: collation
......
...@@ -72,6 +72,10 @@ class Find implements Executable, Explainable ...@@ -72,6 +72,10 @@ class Find implements Executable, Explainable
* *
* Supported options: * Supported options:
* *
* * allowDiskUse (boolean): Enables writing to temporary files. When set
* to true, queries can write data to the _tmp sub-directory in the
* dbPath directory. The default is false.
*
* * allowPartialResults (boolean): Get partial results from a mongos if * * allowPartialResults (boolean): Get partial results from a mongos if
* some shards are inaccessible (instead of throwing an error). * some shards are inaccessible (instead of throwing an error).
* *
...@@ -169,6 +173,10 @@ class Find implements Executable, Explainable ...@@ -169,6 +173,10 @@ class Find implements Executable, Explainable
throw InvalidArgumentException::invalidType('$filter', $filter, 'array or object'); throw InvalidArgumentException::invalidType('$filter', $filter, 'array or object');
} }
if (isset($options['allowDiskUse']) && ! is_bool($options['allowDiskUse'])) {
throw InvalidArgumentException::invalidType('"allowDiskUse" option', $options['allowDiskUse'], 'boolean');
}
if (isset($options['allowPartialResults']) && ! is_bool($options['allowPartialResults'])) { if (isset($options['allowPartialResults']) && ! is_bool($options['allowPartialResults'])) {
throw InvalidArgumentException::invalidType('"allowPartialResults" option', $options['allowPartialResults'], 'boolean'); throw InvalidArgumentException::invalidType('"allowPartialResults" option', $options['allowPartialResults'], 'boolean');
} }
...@@ -416,7 +424,7 @@ class Find implements Executable, Explainable ...@@ -416,7 +424,7 @@ class Find implements Executable, Explainable
} }
} }
foreach (['allowPartialResults', 'batchSize', 'comment', 'hint', 'limit', 'maxAwaitTimeMS', 'maxScan', 'maxTimeMS', 'noCursorTimeout', 'oplogReplay', 'projection', 'readConcern', 'returnKey', 'showRecordId', 'skip', 'snapshot', 'sort'] as $option) { foreach (['allowDiskUse', 'allowPartialResults', 'batchSize', 'comment', 'hint', 'limit', 'maxAwaitTimeMS', 'maxScan', 'maxTimeMS', 'noCursorTimeout', 'oplogReplay', 'projection', 'readConcern', 'returnKey', 'showRecordId', 'skip', 'snapshot', 'sort'] as $option) {
if (isset($this->options[$option])) { if (isset($this->options[$option])) {
$options[$option] = $this->options[$option]; $options[$option] = $this->options[$option];
} }
......
...@@ -15,11 +15,7 @@ use function glob; ...@@ -15,11 +15,7 @@ use function glob;
class CrudSpecTest extends FunctionalTestCase class CrudSpecTest extends FunctionalTestCase
{ {
/** @var array */ /** @var array */
private static $incompleteTests = [ private static $incompleteTests = [];
'find-allowdiskuse: Find does not send allowDiskuse when value is not specified' => 'PHPLIB-500',
'find-allowdiskuse: Find sends allowDiskuse false when false is specified' => 'PHPLIB-500',
'find-allowdiskuse: Find sends allowDiskUse true when true is specified' => 'PHPLIB-500',
];
/** /**
* Assert that the expected and actual command documents match. * Assert that the expected and actual command documents match.
...@@ -29,6 +25,13 @@ class CrudSpecTest extends FunctionalTestCase ...@@ -29,6 +25,13 @@ class CrudSpecTest extends FunctionalTestCase
*/ */
public static function assertCommandMatches(stdClass $expected, stdClass $actual) public static function assertCommandMatches(stdClass $expected, stdClass $actual)
{ {
foreach ($expected as $key => $value) {
if ($value === null) {
static::assertObjectNotHasAttribute($key, $actual);
unset($expected->{$key});
}
}
static::assertDocumentsMatch($expected, $actual); static::assertDocumentsMatch($expected, $actual);
} }
......
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