Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongo-php-library
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sinan
mongo-php-library
Commits
9150bd7d
Unverified
Commit
9150bd7d
authored
Feb 07, 2020
by
Andreas Braun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PHPLIB-500: Support for allowDiskUse on find operations
parent
68d49083
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
40 additions
and
6 deletions
+40
-6
apiargs-MongoDBCollection-method-find-option.yaml
...ncludes/apiargs-MongoDBCollection-method-find-option.yaml
+11
-0
apiargs-MongoDBCollection-method-findOne-option.yaml
...udes/apiargs-MongoDBCollection-method-findOne-option.yaml
+4
-0
apiargs-MongoDBGridFSBucket-method-find-option.yaml
...ludes/apiargs-MongoDBGridFSBucket-method-find-option.yaml
+4
-0
apiargs-MongoDBGridFSBucket-method-findOne-option.yaml
...es/apiargs-MongoDBGridFSBucket-method-findOne-option.yaml
+4
-0
Find.php
src/Operation/Find.php
+9
-1
CrudSpecTest.php
tests/SpecTests/CrudSpecTest.php
+8
-5
No files found.
docs/includes/apiargs-MongoDBCollection-method-find-option.yaml
View file @
9150bd7d
...
...
@@ -47,6 +47,17 @@ operation: ~
optional
:
true
---
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
type
:
integer
description
:
|
...
...
docs/includes/apiargs-MongoDBCollection-method-findOne-option.yaml
View file @
9150bd7d
...
...
@@ -10,6 +10,10 @@ source:
file
:
apiargs-MongoDBCollection-method-find-option.yaml
ref
:
skip
---
source
:
file
:
apiargs-MongoDBCollection-method-find-option.yaml
ref
:
allowDiskUse
---
source
:
file
:
apiargs-MongoDBCollection-common-option.yaml
ref
:
collation
...
...
docs/includes/apiargs-MongoDBGridFSBucket-method-find-option.yaml
View file @
9150bd7d
...
...
@@ -14,6 +14,10 @@ source:
file
:
apiargs-MongoDBCollection-method-find-option.yaml
ref
:
limit
---
source
:
file
:
apiargs-MongoDBCollection-method-find-option.yaml
ref
:
allowDiskUse
---
source
:
file
:
apiargs-MongoDBCollection-method-find-option.yaml
ref
:
batchSize
...
...
docs/includes/apiargs-MongoDBGridFSBucket-method-findOne-option.yaml
View file @
9150bd7d
...
...
@@ -10,6 +10,10 @@ source:
file
:
apiargs-MongoDBCollection-method-find-option.yaml
ref
:
skip
---
source
:
file
:
apiargs-MongoDBCollection-method-find-option.yaml
ref
:
allowDiskUse
---
source
:
file
:
apiargs-MongoDBCollection-common-option.yaml
ref
:
collation
...
...
src/Operation/Find.php
View file @
9150bd7d
...
...
@@ -72,6 +72,10 @@ class Find implements Executable, Explainable
*
* 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
* some shards are inaccessible (instead of throwing an error).
*
...
...
@@ -169,6 +173,10 @@ class Find implements Executable, Explainable
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'
]))
{
throw
InvalidArgumentException
::
invalidType
(
'"allowPartialResults" option'
,
$options
[
'allowPartialResults'
],
'boolean'
);
}
...
...
@@ -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
([
'allow
DiskUse'
,
'allow
PartialResults'
,
'batchSize'
,
'comment'
,
'hint'
,
'limit'
,
'maxAwaitTimeMS'
,
'maxScan'
,
'maxTimeMS'
,
'noCursorTimeout'
,
'oplogReplay'
,
'projection'
,
'readConcern'
,
'returnKey'
,
'showRecordId'
,
'skip'
,
'snapshot'
,
'sort'
]
as
$option
)
{
if
(
isset
(
$this
->
options
[
$option
]))
{
$options
[
$option
]
=
$this
->
options
[
$option
];
}
...
...
tests/SpecTests/CrudSpecTest.php
View file @
9150bd7d
...
...
@@ -15,11 +15,7 @@ use function glob;
class
CrudSpecTest
extends
FunctionalTestCase
{
/** @var array */
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'
,
];
private
static
$incompleteTests
=
[];
/**
* Assert that the expected and actual command documents match.
...
...
@@ -29,6 +25,13 @@ class CrudSpecTest extends FunctionalTestCase
*/
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
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment