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
142d24ec
Commit
142d24ec
authored
Jan 31, 2018
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PHPLIB-302: Support session option for operations
parent
8b808043
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
103 changed files
with
1196 additions
and
19 deletions
+1196
-19
apiargs-MongoDBClient-method-dropDatabase-option.yaml
...des/apiargs-MongoDBClient-method-dropDatabase-option.yaml
+4
-0
apiargs-MongoDBClient-method-listDatabases-option.yaml
...es/apiargs-MongoDBClient-method-listDatabases-option.yaml
+4
-0
apiargs-MongoDBCollection-method-aggregate-option.yaml
...es/apiargs-MongoDBCollection-method-aggregate-option.yaml
+4
-0
apiargs-MongoDBCollection-method-bulkWrite-option.yaml
...es/apiargs-MongoDBCollection-method-bulkWrite-option.yaml
+4
-0
apiargs-MongoDBCollection-method-count-option.yaml
...cludes/apiargs-MongoDBCollection-method-count-option.yaml
+4
-0
apiargs-MongoDBCollection-method-createIndex-option.yaml
.../apiargs-MongoDBCollection-method-createIndex-option.yaml
+4
-0
apiargs-MongoDBCollection-method-createIndexes-option.yaml
...piargs-MongoDBCollection-method-createIndexes-option.yaml
+4
-0
apiargs-MongoDBCollection-method-deleteMany-option.yaml
...s/apiargs-MongoDBCollection-method-deleteMany-option.yaml
+4
-0
apiargs-MongoDBCollection-method-deleteOne-option.yaml
...es/apiargs-MongoDBCollection-method-deleteOne-option.yaml
+4
-0
apiargs-MongoDBCollection-method-distinct-option.yaml
...des/apiargs-MongoDBCollection-method-distinct-option.yaml
+4
-0
apiargs-MongoDBCollection-method-drop-option.yaml
...ncludes/apiargs-MongoDBCollection-method-drop-option.yaml
+4
-0
apiargs-MongoDBCollection-method-dropIndex-option.yaml
...es/apiargs-MongoDBCollection-method-dropIndex-option.yaml
+4
-0
apiargs-MongoDBCollection-method-dropIndexes-option.yaml
.../apiargs-MongoDBCollection-method-dropIndexes-option.yaml
+4
-0
apiargs-MongoDBCollection-method-find-option.yaml
...ncludes/apiargs-MongoDBCollection-method-find-option.yaml
+4
-0
apiargs-MongoDBCollection-method-findOne-option.yaml
...udes/apiargs-MongoDBCollection-method-findOne-option.yaml
+4
-0
apiargs-MongoDBCollection-method-findOneAndDelete-option.yaml
...rgs-MongoDBCollection-method-findOneAndDelete-option.yaml
+4
-0
apiargs-MongoDBCollection-method-findOneAndReplace-option.yaml
...gs-MongoDBCollection-method-findOneAndReplace-option.yaml
+4
-0
apiargs-MongoDBCollection-method-findOneAndUpdate-option.yaml
...rgs-MongoDBCollection-method-findOneAndUpdate-option.yaml
+4
-0
apiargs-MongoDBCollection-method-insertMany-option.yaml
...s/apiargs-MongoDBCollection-method-insertMany-option.yaml
+4
-0
apiargs-MongoDBCollection-method-insertOne-option.yaml
...es/apiargs-MongoDBCollection-method-insertOne-option.yaml
+4
-0
apiargs-MongoDBCollection-method-listIndexes-option.yaml
.../apiargs-MongoDBCollection-method-listIndexes-option.yaml
+4
-0
apiargs-MongoDBCollection-method-mapReduce-option.yaml
...es/apiargs-MongoDBCollection-method-mapReduce-option.yaml
+4
-0
apiargs-MongoDBCollection-method-replaceOne-option.yaml
...s/apiargs-MongoDBCollection-method-replaceOne-option.yaml
+4
-0
apiargs-MongoDBCollection-method-updateMany-option.yaml
...s/apiargs-MongoDBCollection-method-updateMany-option.yaml
+4
-0
apiargs-MongoDBCollection-method-updateOne-option.yaml
...es/apiargs-MongoDBCollection-method-updateOne-option.yaml
+4
-0
apiargs-MongoDBDatabase-method-command-option.yaml
...cludes/apiargs-MongoDBDatabase-method-command-option.yaml
+4
-0
apiargs-MongoDBDatabase-method-createCollection-option.yaml
...iargs-MongoDBDatabase-method-createCollection-option.yaml
+4
-0
apiargs-MongoDBDatabase-method-drop-option.yaml
.../includes/apiargs-MongoDBDatabase-method-drop-option.yaml
+4
-0
apiargs-MongoDBDatabase-method-dropCollection-option.yaml
...apiargs-MongoDBDatabase-method-dropCollection-option.yaml
+4
-0
apiargs-MongoDBDatabase-method-listCollections-option.yaml
...piargs-MongoDBDatabase-method-listCollections-option.yaml
+4
-0
apiargs-common-option.yaml
docs/includes/apiargs-common-option.yaml
+11
-0
Aggregate.php
src/Operation/Aggregate.php
+13
-0
BulkWrite.php
src/Operation/BulkWrite.php
+31
-2
Count.php
src/Operation/Count.php
+13
-0
CreateCollection.php
src/Operation/CreateCollection.php
+13
-0
CreateIndexes.php
src/Operation/CreateIndexes.php
+13
-0
DatabaseCommand.php
src/Operation/DatabaseCommand.php
+31
-3
Delete.php
src/Operation/Delete.php
+31
-2
DeleteMany.php
src/Operation/DeleteMany.php
+4
-0
DeleteOne.php
src/Operation/DeleteOne.php
+4
-0
Distinct.php
src/Operation/Distinct.php
+13
-0
DropCollection.php
src/Operation/DropCollection.php
+13
-0
DropDatabase.php
src/Operation/DropDatabase.php
+13
-0
DropIndexes.php
src/Operation/DropIndexes.php
+13
-0
Find.php
src/Operation/Find.php
+31
-3
FindAndModify.php
src/Operation/FindAndModify.php
+13
-0
FindOne.php
src/Operation/FindOne.php
+4
-0
FindOneAndDelete.php
src/Operation/FindOneAndDelete.php
+4
-0
FindOneAndReplace.php
src/Operation/FindOneAndReplace.php
+4
-0
FindOneAndUpdate.php
src/Operation/FindOneAndUpdate.php
+4
-0
InsertMany.php
src/Operation/InsertMany.php
+31
-2
InsertOne.php
src/Operation/InsertOne.php
+31
-2
ListCollections.php
src/Operation/ListCollections.php
+30
-1
ListDatabases.php
src/Operation/ListDatabases.php
+30
-1
ListIndexes.php
src/Operation/ListIndexes.php
+30
-1
MapReduce.php
src/Operation/MapReduce.php
+13
-0
ReplaceOne.php
src/Operation/ReplaceOne.php
+4
-0
Update.php
src/Operation/Update.php
+31
-2
UpdateMany.php
src/Operation/UpdateMany.php
+4
-0
UpdateOne.php
src/Operation/UpdateOne.php
+4
-0
Watch.php
src/Operation/Watch.php
+5
-0
AggregateFunctionalTest.php
tests/Operation/AggregateFunctionalTest.php
+23
-0
AggregateTest.php
tests/Operation/AggregateTest.php
+4
-0
BulkWriteFunctionalTest.php
tests/Operation/BulkWriteFunctionalTest.php
+25
-0
BulkWriteTest.php
tests/Operation/BulkWriteTest.php
+4
-0
CountFunctionalTest.php
tests/Operation/CountFunctionalTest.php
+23
-0
CountTest.php
tests/Operation/CountTest.php
+4
-0
CreateCollectionFunctionalTest.php
tests/Operation/CreateCollectionFunctionalTest.php
+22
-0
CreateCollectionTest.php
tests/Operation/CreateCollectionTest.php
+4
-0
CreateIndexesFunctionalTest.php
tests/Operation/CreateIndexesFunctionalTest.php
+23
-0
CreateIndexesTest.php
tests/Operation/CreateIndexesTest.php
+4
-0
DatabaseCommandFunctionalTest.php
tests/Operation/DatabaseCommandFunctionalTest.php
+32
-0
DatabaseCommandTest.php
tests/Operation/DatabaseCommandTest.php
+4
-0
DeleteFunctionalTest.php
tests/Operation/DeleteFunctionalTest.php
+26
-0
DeleteTest.php
tests/Operation/DeleteTest.php
+4
-0
DistinctFunctionalTest.php
tests/Operation/DistinctFunctionalTest.php
+24
-0
DistinctTest.php
tests/Operation/DistinctTest.php
+4
-0
DropCollectionFunctionalTest.php
tests/Operation/DropCollectionFunctionalTest.php
+22
-0
DropCollectionTest.php
tests/Operation/DropCollectionTest.php
+4
-0
DropDatabaseFunctionalTest.php
tests/Operation/DropDatabaseFunctionalTest.php
+21
-0
DropDatabaseTest.php
tests/Operation/DropDatabaseTest.php
+4
-0
DropIndexesFunctionalTest.php
tests/Operation/DropIndexesFunctionalTest.php
+26
-0
DropIndexesTest.php
tests/Operation/DropIndexesTest.php
+4
-0
FindAndModifyFunctionalTest.php
tests/Operation/FindAndModifyFunctionalTest.php
+22
-0
FindAndModifyTest.php
tests/Operation/FindAndModifyTest.php
+4
-0
FindFunctionalTest.php
tests/Operation/FindFunctionalTest.php
+23
-0
FindTest.php
tests/Operation/FindTest.php
+4
-0
FunctionalTestCase.php
tests/Operation/FunctionalTestCase.php
+5
-0
InsertManyFunctionalTest.php
tests/Operation/InsertManyFunctionalTest.php
+25
-0
InsertManyTest.php
tests/Operation/InsertManyTest.php
+4
-0
InsertOneFunctionalTest.php
tests/Operation/InsertOneFunctionalTest.php
+25
-0
InsertOneTest.php
tests/Operation/InsertOneTest.php
+4
-0
ListCollectionsFunctionalTest.php
tests/Operation/ListCollectionsFunctionalTest.php
+23
-0
ListCollectionsTest.php
tests/Operation/ListCollectionsTest.php
+4
-0
ListDatabasesFunctionalTest.php
tests/Operation/ListDatabasesFunctionalTest.php
+30
-0
ListDatabasesTest.php
tests/Operation/ListDatabasesTest.php
+4
-0
ListIndexesFunctionalTest.php
tests/Operation/ListIndexesFunctionalTest.php
+24
-0
ListIndexesTest.php
tests/Operation/ListIndexesTest.php
+4
-0
MapReduceFunctionalTest.php
tests/Operation/MapReduceFunctionalTest.php
+27
-0
MapReduceTest.php
tests/Operation/MapReduceTest.php
+4
-0
UpdateFunctionalTest.php
tests/Operation/UpdateFunctionalTest.php
+26
-0
UpdateTest.php
tests/Operation/UpdateTest.php
+4
-0
TestCase.php
tests/TestCase.php
+10
-0
No files found.
docs/includes/apiargs-MongoDBClient-method-dropDatabase-option.yaml
View file @
142d24ec
source
:
file
:
apiargs-common-option.yaml
ref
:
session
---
source
:
file
:
apiargs-common-option.yaml
ref
:
typeMap
...
...
docs/includes/apiargs-MongoDBClient-method-listDatabases-option.yaml
View file @
142d24ec
source
:
file
:
apiargs-common-option.yaml
ref
:
maxTimeMS
---
source
:
file
:
apiargs-common-option.yaml
ref
:
session
...
docs/includes/apiargs-MongoDBCollection-method-aggregate-option.yaml
View file @
142d24ec
...
...
@@ -68,6 +68,10 @@ source:
post
:
|
This option will be ignored when using the :ref:`$out <agg-out>` stage.
---
source
:
file
:
apiargs-common-option.yaml
ref
:
session
---
source
:
file
:
apiargs-MongoDBCollection-common-option.yaml
ref
:
typeMap
...
...
docs/includes/apiargs-MongoDBCollection-method-bulkWrite-option.yaml
View file @
142d24ec
...
...
@@ -17,6 +17,10 @@ interface: phpmethod
operation
:
~
optional
:
true
---
source
:
file
:
apiargs-common-option.yaml
ref
:
session
---
source
:
file
:
apiargs-MongoDBCollection-common-option.yaml
ref
:
writeConcern
...
...
docs/includes/apiargs-MongoDBCollection-method-count-option.yaml
View file @
142d24ec
...
...
@@ -38,6 +38,10 @@ source:
file
:
apiargs-MongoDBCollection-common-option.yaml
ref
:
readPreference
---
source
:
file
:
apiargs-common-option.yaml
ref
:
session
---
arg_name
:
option
name
:
skip
type
:
integer
...
...
docs/includes/apiargs-MongoDBCollection-method-createIndex-option.yaml
View file @
142d24ec
...
...
@@ -75,6 +75,10 @@ interface: phpmethod
operation
:
~
optional
:
true
---
source
:
file
:
apiargs-common-option.yaml
ref
:
session
---
source
:
file
:
apiargs-MongoDBCollection-common-option.yaml
ref
:
writeConcern
...
...
docs/includes/apiargs-MongoDBCollection-method-createIndexes-option.yaml
View file @
142d24ec
...
...
@@ -2,6 +2,10 @@ source:
file
:
apiargs-common-option.yaml
ref
:
maxTimeMS
---
source
:
file
:
apiargs-common-option.yaml
ref
:
session
---
source
:
file
:
apiargs-MongoDBCollection-common-option.yaml
ref
:
writeConcern
...
...
docs/includes/apiargs-MongoDBCollection-method-deleteMany-option.yaml
View file @
142d24ec
...
...
@@ -2,6 +2,10 @@ source:
file
:
apiargs-MongoDBCollection-common-option.yaml
ref
:
collation
---
source
:
file
:
apiargs-common-option.yaml
ref
:
session
---
source
:
file
:
apiargs-MongoDBCollection-common-option.yaml
ref
:
writeConcern
...
...
docs/includes/apiargs-MongoDBCollection-method-deleteOne-option.yaml
View file @
142d24ec
...
...
@@ -2,6 +2,10 @@ source:
file
:
apiargs-MongoDBCollection-common-option.yaml
ref
:
collation
---
source
:
file
:
apiargs-common-option.yaml
ref
:
session
---
source
:
file
:
apiargs-MongoDBCollection-common-option.yaml
ref
:
writeConcern
...
...
docs/includes/apiargs-MongoDBCollection-method-distinct-option.yaml
View file @
142d24ec
...
...
@@ -13,4 +13,8 @@ source:
source
:
file
:
apiargs-MongoDBCollection-common-option.yaml
ref
:
readPreference
---
source
:
file
:
apiargs-common-option.yaml
ref
:
session
...
docs/includes/apiargs-MongoDBCollection-method-drop-option.yaml
View file @
142d24ec
...
...
@@ -4,6 +4,10 @@ source:
post
:
|
This will be used for the returned command result document.
---
source
:
file
:
apiargs-common-option.yaml
ref
:
session
---
source
:
file
:
apiargs-MongoDBCollection-common-option.yaml
ref
:
writeConcern
...
...
docs/includes/apiargs-MongoDBCollection-method-dropIndex-option.yaml
View file @
142d24ec
...
...
@@ -2,6 +2,10 @@ source:
file
:
apiargs-common-option.yaml
ref
:
maxTimeMS
---
source
:
file
:
apiargs-common-option.yaml
ref
:
session
---
source
:
file
:
apiargs-MongoDBCollection-common-option.yaml
ref
:
typeMap
...
...
docs/includes/apiargs-MongoDBCollection-method-dropIndexes-option.yaml
View file @
142d24ec
...
...
@@ -2,6 +2,10 @@ source:
file
:
apiargs-common-option.yaml
ref
:
maxTimeMS
---
source
:
file
:
apiargs-common-option.yaml
ref
:
session
---
source
:
file
:
apiargs-MongoDBCollection-common-option.yaml
ref
:
typeMap
...
...
docs/includes/apiargs-MongoDBCollection-method-find-option.yaml
View file @
142d24ec
...
...
@@ -125,6 +125,10 @@ source:
file
:
apiargs-MongoDBCollection-common-option.yaml
ref
:
readPreference
---
source
:
file
:
apiargs-common-option.yaml
ref
:
session
---
arg_name
:
option
name
:
max
type
:
array|object
...
...
docs/includes/apiargs-MongoDBCollection-method-findOne-option.yaml
View file @
142d24ec
...
...
@@ -34,6 +34,10 @@ source:
file
:
apiargs-MongoDBCollection-common-option.yaml
ref
:
readPreference
---
source
:
file
:
apiargs-common-option.yaml
ref
:
session
---
source
:
file
:
apiargs-MongoDBCollection-common-option.yaml
ref
:
typeMap
...
...
docs/includes/apiargs-MongoDBCollection-method-findOneAndDelete-option.yaml
View file @
142d24ec
...
...
@@ -14,6 +14,10 @@ source:
file
:
apiargs-common-option.yaml
ref
:
maxTimeMS
---
source
:
file
:
apiargs-common-option.yaml
ref
:
session
---
source
:
file
:
apiargs-MongoDBCollection-common-option.yaml
ref
:
typeMap
...
...
docs/includes/apiargs-MongoDBCollection-method-findOneAndReplace-option.yaml
View file @
142d24ec
...
...
@@ -31,6 +31,10 @@ interface: phpmethod
operation
:
~
optional
:
true
---
source
:
file
:
apiargs-common-option.yaml
ref
:
session
---
source
:
file
:
apiargs-MongoDBCollection-common-option.yaml
ref
:
typeMap
...
...
docs/includes/apiargs-MongoDBCollection-method-findOneAndUpdate-option.yaml
View file @
142d24ec
...
...
@@ -35,6 +35,10 @@ interface: phpmethod
operation
:
~
optional
:
true
---
source
:
file
:
apiargs-common-option.yaml
ref
:
session
---
source
:
file
:
apiargs-MongoDBCollection-common-option.yaml
ref
:
typeMap
...
...
docs/includes/apiargs-MongoDBCollection-method-insertMany-option.yaml
View file @
142d24ec
...
...
@@ -6,6 +6,10 @@ source:
file
:
apiargs-MongoDBCollection-method-bulkWrite-option.yaml
ref
:
ordered
---
source
:
file
:
apiargs-common-option.yaml
ref
:
session
---
source
:
file
:
apiargs-MongoDBCollection-common-option.yaml
ref
:
writeConcern
...
...
docs/includes/apiargs-MongoDBCollection-method-insertOne-option.yaml
View file @
142d24ec
...
...
@@ -2,6 +2,10 @@ source:
file
:
apiargs-MongoDBCollection-common-option.yaml
ref
:
bypassDocumentValidation
---
source
:
file
:
apiargs-common-option.yaml
ref
:
session
---
source
:
file
:
apiargs-MongoDBCollection-common-option.yaml
ref
:
writeConcern
...
...
docs/includes/apiargs-MongoDBCollection-method-listIndexes-option.yaml
View file @
142d24ec
source
:
file
:
apiargs-common-option.yaml
ref
:
maxTimeMS
---
source
:
file
:
apiargs-common-option.yaml
ref
:
session
...
docs/includes/apiargs-MongoDBCollection-method-mapReduce-option.yaml
View file @
142d24ec
...
...
@@ -70,6 +70,10 @@ interface: phpmethod
operation
:
~
optional
:
true
---
source
:
file
:
apiargs-common-option.yaml
ref
:
session
---
source
:
file
:
apiargs-MongoDBCollection-method-find-option.yaml
ref
:
sort
...
...
docs/includes/apiargs-MongoDBCollection-method-replaceOne-option.yaml
View file @
142d24ec
...
...
@@ -10,6 +10,10 @@ source:
file
:
apiargs-MongoDBCollection-common-option.yaml
ref
:
collation
---
source
:
file
:
apiargs-common-option.yaml
ref
:
session
---
source
:
file
:
apiargs-MongoDBCollection-common-option.yaml
ref
:
writeConcern
...
...
docs/includes/apiargs-MongoDBCollection-method-updateMany-option.yaml
View file @
142d24ec
...
...
@@ -14,6 +14,10 @@ source:
file
:
apiargs-MongoDBCollection-common-option.yaml
ref
:
collation
---
source
:
file
:
apiargs-common-option.yaml
ref
:
session
---
source
:
file
:
apiargs-MongoDBCollection-common-option.yaml
ref
:
writeConcern
...
...
docs/includes/apiargs-MongoDBCollection-method-updateOne-option.yaml
View file @
142d24ec
...
...
@@ -10,6 +10,10 @@ source:
file
:
apiargs-MongoDBCollection-common-option.yaml
ref
:
collation
---
source
:
file
:
apiargs-common-option.yaml
ref
:
session
---
source
:
file
:
apiargs-MongoDBCollection-common-option.yaml
ref
:
writeConcern
...
...
docs/includes/apiargs-MongoDBDatabase-method-command-option.yaml
View file @
142d24ec
...
...
@@ -5,6 +5,10 @@ description: |
:manual:`Read preference </reference/read-preference>` to use for the
operation. Defaults to the database's read preference.
---
source
:
file
:
apiargs-common-option.yaml
ref
:
session
---
source
:
file
:
apiargs-MongoDBDatabase-common-option.yaml
ref
:
typeMap
...
...
docs/includes/apiargs-MongoDBDatabase-method-createCollection-option.yaml
View file @
142d24ec
...
...
@@ -93,6 +93,10 @@ source:
file
:
apiargs-common-option.yaml
ref
:
maxTimeMS
---
source
:
file
:
apiargs-common-option.yaml
ref
:
session
---
arg_name
:
option
name
:
size
type
:
integer
...
...
docs/includes/apiargs-MongoDBDatabase-method-drop-option.yaml
View file @
142d24ec
source
:
file
:
apiargs-common-option.yaml
ref
:
session
---
source
:
file
:
apiargs-MongoDBDatabase-common-option.yaml
ref
:
typeMap
...
...
docs/includes/apiargs-MongoDBDatabase-method-dropCollection-option.yaml
View file @
142d24ec
source
:
file
:
apiargs-common-option.yaml
ref
:
session
---
source
:
file
:
apiargs-MongoDBDatabase-common-option.yaml
ref
:
typeMap
...
...
docs/includes/apiargs-MongoDBDatabase-method-listCollections-option.yaml
View file @
142d24ec
...
...
@@ -12,4 +12,8 @@ optional: true
source
:
file
:
apiargs-common-option.yaml
ref
:
maxTimeMS
---
source
:
file
:
apiargs-common-option.yaml
ref
:
session
...
docs/includes/apiargs-common-option.yaml
View file @
142d24ec
...
...
@@ -36,6 +36,17 @@ replacement:
parent
:
"
client"
---
arg_name
:
option
name
:
session
type
:
:php:`MongoDB\\Driver\\Session <class.mongodb-driver-session>`
description
:
|
Client session to associate with the operation.
Sessions are not supported for server versions prior to 3.6.
interface
:
phpmethod
operation
:
~
optional
:
true
---
arg_name
:
option
name
:
typeMap
type
:
array
description
:
|
...
...
src/Operation/Aggregate.php
View file @
142d24ec
...
...
@@ -21,6 +21,7 @@ use MongoDB\Driver\Command;
use
MongoDB\Driver\ReadConcern
;
use
MongoDB\Driver\ReadPreference
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Session
;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Driver\Exception\RuntimeException
as
DriverRuntimeException
;
use
MongoDB\Exception\InvalidArgumentException
;
...
...
@@ -93,6 +94,10 @@ class Aggregate implements Executable
*
* This option is ignored if the $out stage is specified.
*
* * session (MongoDB\Driver\Session): Client session.
*
* Sessions are not supported for server versions < 3.6.
*
* * typeMap (array): Type map for BSON deserialization. This will be
* applied to the returned Cursor (it is not sent to the server).
*
...
...
@@ -175,6 +180,10 @@ class Aggregate implements Executable
throw
InvalidArgumentException
::
invalidType
(
'"readPreference" option'
,
$options
[
'readPreference'
],
'MongoDB\Driver\ReadPreference'
);
}
if
(
isset
(
$options
[
'session'
])
&&
!
$options
[
'session'
]
instanceof
Session
)
{
throw
InvalidArgumentException
::
invalidType
(
'"session" option'
,
$options
[
'session'
],
'MongoDB\Driver\Session'
);
}
if
(
isset
(
$options
[
'typeMap'
])
&&
!
is_array
(
$options
[
'typeMap'
]))
{
throw
InvalidArgumentException
::
invalidType
(
'"typeMap" option'
,
$options
[
'typeMap'
],
'array'
);
}
...
...
@@ -330,6 +339,10 @@ class Aggregate implements Executable
$options
[
'readPreference'
]
=
$this
->
options
[
'readPreference'
];
}
if
(
isset
(
$this
->
options
[
'session'
]))
{
$options
[
'session'
]
=
$this
->
options
[
'session'
];
}
if
(
$hasOutStage
&&
isset
(
$this
->
options
[
'writeConcern'
]))
{
$options
[
'writeConcern'
]
=
$this
->
options
[
'writeConcern'
];
}
...
...
src/Operation/BulkWrite.php
View file @
142d24ec
...
...
@@ -20,6 +20,7 @@ namespace MongoDB\Operation;
use
MongoDB\BulkWriteResult
;
use
MongoDB\Driver\BulkWrite
as
Bulk
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Session
;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Driver\Exception\RuntimeException
as
DriverRuntimeException
;
use
MongoDB\Exception\InvalidArgumentException
;
...
...
@@ -106,6 +107,10 @@ class BulkWrite implements Executable
* performing the remaining writes. If false, when a write fails,
* continue with the remaining writes, if any. The default is true.
*
* * session (MongoDB\Driver\Session): Client session.
*
* Sessions are not supported for server versions < 3.6.
*
* * writeConcern (MongoDB\Driver\WriteConcern): Write concern.
*
* @param string $databaseName Database name
...
...
@@ -280,6 +285,10 @@ class BulkWrite implements Executable
throw
InvalidArgumentException
::
invalidType
(
'"ordered" option'
,
$options
[
'ordered'
],
'boolean'
);
}
if
(
isset
(
$options
[
'session'
])
&&
!
$options
[
'session'
]
instanceof
Session
)
{
throw
InvalidArgumentException
::
invalidType
(
'"session" option'
,
$options
[
'session'
],
'MongoDB\Driver\Session'
);
}
if
(
isset
(
$options
[
'writeConcern'
])
&&
!
$options
[
'writeConcern'
]
instanceof
WriteConcern
)
{
throw
InvalidArgumentException
::
invalidType
(
'"writeConcern" option'
,
$options
[
'writeConcern'
],
'MongoDB\Driver\WriteConcern'
);
}
...
...
@@ -343,9 +352,29 @@ class BulkWrite implements Executable
}
}
$writeConcern
=
isset
(
$this
->
options
[
'writeConcern'
])
?
$this
->
options
[
'writeConcern'
]
:
null
;
$writeResult
=
$server
->
executeBulkWrite
(
$this
->
databaseName
.
'.'
.
$this
->
collectionName
,
$bulk
,
$writeConcern
);
$writeResult
=
$server
->
executeBulkWrite
(
$this
->
databaseName
.
'.'
.
$this
->
collectionName
,
$bulk
,
$this
->
createOptions
());
return
new
BulkWriteResult
(
$writeResult
,
$insertedIds
);
}
/**
* Create options for executing the bulk write.
*
* @see http://php.net/manual/en/mongodb-driver-server.executebulkwrite.php
* @return array
*/
private
function
createOptions
()
{
$options
=
[];
if
(
isset
(
$this
->
options
[
'session'
]))
{
$options
[
'session'
]
=
$this
->
options
[
'session'
];
}
if
(
isset
(
$this
->
options
[
'writeConcern'
]))
{
$options
[
'writeConcern'
]
=
$this
->
options
[
'writeConcern'
];
}
return
$options
;
}
}
src/Operation/Count.php
View file @
142d24ec
...
...
@@ -21,6 +21,7 @@ use MongoDB\Driver\Command;
use
MongoDB\Driver\ReadConcern
;
use
MongoDB\Driver\ReadPreference
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Session
;
use
MongoDB\Driver\Exception\RuntimeException
as
DriverRuntimeException
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\UnexpectedValueException
;
...
...
@@ -69,6 +70,10 @@ class Count implements Executable
*
* * readPreference (MongoDB\Driver\ReadPreference): Read preference.
*
* * session (MongoDB\Driver\Session): Client session.
*
* Sessions are not supported for server versions < 3.6.
*
* * skip (integer): The number of documents to skip before returning the
* documents.
*
...
...
@@ -108,6 +113,10 @@ class Count implements Executable
throw
InvalidArgumentException
::
invalidType
(
'"readPreference" option'
,
$options
[
'readPreference'
],
'MongoDB\Driver\ReadPreference'
);
}
if
(
isset
(
$options
[
'session'
])
&&
!
$options
[
'session'
]
instanceof
Session
)
{
throw
InvalidArgumentException
::
invalidType
(
'"session" option'
,
$options
[
'session'
],
'MongoDB\Driver\Session'
);
}
if
(
isset
(
$options
[
'skip'
])
&&
!
is_integer
(
$options
[
'skip'
]))
{
throw
InvalidArgumentException
::
invalidType
(
'"skip" option'
,
$options
[
'skip'
],
'integer'
);
}
...
...
@@ -201,6 +210,10 @@ class Count implements Executable
$options
[
'readPreference'
]
=
$this
->
options
[
'readPreference'
];
}
if
(
isset
(
$this
->
options
[
'session'
]))
{
$options
[
'session'
]
=
$this
->
options
[
'session'
];
}
return
$options
;
}
}
src/Operation/CreateCollection.php
View file @
142d24ec
...
...
@@ -19,6 +19,7 @@ namespace MongoDB\Operation;
use
MongoDB\Driver\Command
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Session
;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Driver\Exception\RuntimeException
as
DriverRuntimeException
;
use
MongoDB\Exception\InvalidArgumentException
;
...
...
@@ -74,6 +75,10 @@ class CreateCollection implements Executable
* * maxTimeMS (integer): The maximum amount of time to allow the query to
* run.
*
* * session (MongoDB\Driver\Session): Client session.
*
* Sessions are not supported for server versions < 3.6.
*
* * size (integer): The maximum number of bytes for a capped collection.
*
* * storageEngine (document): Storage engine options.
...
...
@@ -129,6 +134,10 @@ class CreateCollection implements Executable
throw
InvalidArgumentException
::
invalidType
(
'"maxTimeMS" option'
,
$options
[
'maxTimeMS'
],
'integer'
);
}
if
(
isset
(
$options
[
'session'
])
&&
!
$options
[
'session'
]
instanceof
Session
)
{
throw
InvalidArgumentException
::
invalidType
(
'"session" option'
,
$options
[
'session'
],
'MongoDB\Driver\Session'
);
}
if
(
isset
(
$options
[
'size'
])
&&
!
is_integer
(
$options
[
'size'
]))
{
throw
InvalidArgumentException
::
invalidType
(
'"size" option'
,
$options
[
'size'
],
'integer'
);
}
...
...
@@ -228,6 +237,10 @@ class CreateCollection implements Executable
{
$options
=
[];
if
(
isset
(
$this
->
options
[
'session'
]))
{
$options
[
'session'
]
=
$this
->
options
[
'session'
];
}
if
(
isset
(
$this
->
options
[
'writeConcern'
]))
{
$options
[
'writeConcern'
]
=
$this
->
options
[
'writeConcern'
];
}
...
...
src/Operation/CreateIndexes.php
View file @
142d24ec
...
...
@@ -20,6 +20,7 @@ namespace MongoDB\Operation;
use
MongoDB\Driver\BulkWrite
as
Bulk
;
use
MongoDB\Driver\Command
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Session
;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Driver\Exception\RuntimeException
as
DriverRuntimeException
;
use
MongoDB\Exception\InvalidArgumentException
;
...
...
@@ -53,6 +54,10 @@ class CreateIndexes implements Executable
* * maxTimeMS (integer): The maximum amount of time to allow the query to
* run.
*
* * session (MongoDB\Driver\Session): Client session.
*
* Sessions are not supported for server versions < 3.6.
*
* * writeConcern (MongoDB\Driver\WriteConcern): Write concern.
*
* This is not supported for server versions < 3.4 and will result in an
...
...
@@ -98,6 +103,10 @@ class CreateIndexes implements Executable
throw
InvalidArgumentException
::
invalidType
(
'"maxTimeMS" option'
,
$options
[
'maxTimeMS'
],
'integer'
);
}
if
(
isset
(
$options
[
'session'
])
&&
!
$options
[
'session'
]
instanceof
Session
)
{
throw
InvalidArgumentException
::
invalidType
(
'"session" option'
,
$options
[
'session'
],
'MongoDB\Driver\Session'
);
}
if
(
isset
(
$options
[
'writeConcern'
])
&&
!
$options
[
'writeConcern'
]
instanceof
WriteConcern
)
{
throw
InvalidArgumentException
::
invalidType
(
'"writeConcern" option'
,
$options
[
'writeConcern'
],
'MongoDB\Driver\WriteConcern'
);
}
...
...
@@ -145,6 +154,10 @@ class CreateIndexes implements Executable
{
$options
=
[];
if
(
isset
(
$this
->
options
[
'session'
]))
{
$options
[
'session'
]
=
$this
->
options
[
'session'
];
}
if
(
isset
(
$this
->
options
[
'writeConcern'
]))
{
$options
[
'writeConcern'
]
=
$this
->
options
[
'writeConcern'
];
}
...
...
src/Operation/DatabaseCommand.php
View file @
142d24ec
...
...
@@ -21,6 +21,7 @@ use MongoDB\Driver\Command;
use
MongoDB\Driver\Cursor
;
use
MongoDB\Driver\ReadPreference
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Session
;
use
MongoDB\Exception\InvalidArgumentException
;
/**
...
...
@@ -46,6 +47,10 @@ class DatabaseCommand implements Executable
* the wire protocol accordingly or adds the read preference to the
* command document, respectively.
*
* * session (MongoDB\Driver\Session): Client session.
*
* Sessions are not supported for server versions < 3.6.
*
* * typeMap (array): Type map for BSON deserialization. This will be
* applied to the returned Cursor (it is not sent to the server).
*
...
...
@@ -64,6 +69,10 @@ class DatabaseCommand implements Executable
throw
InvalidArgumentException
::
invalidType
(
'"readPreference" option'
,
$options
[
'readPreference'
],
'MongoDB\Driver\ReadPreference'
);
}
if
(
isset
(
$options
[
'session'
])
&&
!
$options
[
'session'
]
instanceof
Session
)
{
throw
InvalidArgumentException
::
invalidType
(
'"session" option'
,
$options
[
'session'
],
'MongoDB\Driver\Session'
);
}
if
(
isset
(
$options
[
'typeMap'
])
&&
!
is_array
(
$options
[
'typeMap'
]))
{
throw
InvalidArgumentException
::
invalidType
(
'"typeMap" option'
,
$options
[
'typeMap'
],
'array'
);
}
...
...
@@ -82,9 +91,7 @@ class DatabaseCommand implements Executable
*/
public
function
execute
(
Server
$server
)
{
$readPreference
=
isset
(
$this
->
options
[
'readPreference'
])
?
$this
->
options
[
'readPreference'
]
:
null
;
$cursor
=
$server
->
executeCommand
(
$this
->
databaseName
,
$this
->
command
,
$readPreference
);
$cursor
=
$server
->
executeCommand
(
$this
->
databaseName
,
$this
->
command
,
$this
->
createOptions
());
if
(
isset
(
$this
->
options
[
'typeMap'
]))
{
$cursor
->
setTypeMap
(
$this
->
options
[
'typeMap'
]);
...
...
@@ -92,4 +99,25 @@ class DatabaseCommand implements Executable
return
$cursor
;
}
/**
* Create options for executing the command.
*
* @see http://php.net/manual/en/mongodb-driver-server.executecommand.php
* @return array
*/
private
function
createOptions
()
{
$options
=
[];
if
(
isset
(
$this
->
options
[
'readPreference'
]))
{
$options
[
'readPreference'
]
=
$this
->
options
[
'readPreference'
];
}
if
(
isset
(
$this
->
options
[
'session'
]))
{
$options
[
'session'
]
=
$this
->
options
[
'session'
];
}
return
$options
;
}
}
src/Operation/Delete.php
View file @
142d24ec
...
...
@@ -20,6 +20,7 @@ namespace MongoDB\Operation;
use
MongoDB\DeleteResult
;
use
MongoDB\Driver\BulkWrite
as
Bulk
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Session
;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Driver\Exception\RuntimeException
as
DriverRuntimeException
;
use
MongoDB\Exception\InvalidArgumentException
;
...
...
@@ -54,6 +55,10 @@ class Delete implements Executable
* This is not supported for server versions < 3.4 and will result in an
* exception at execution time if used.
*
* * session (MongoDB\Driver\Session): Client session.
*
* Sessions are not supported for server versions < 3.6.
*
* * writeConcern (MongoDB\Driver\WriteConcern): Write concern.
*
* @param string $databaseName Database name
...
...
@@ -79,6 +84,10 @@ class Delete implements Executable
throw
InvalidArgumentException
::
invalidType
(
'"collation" option'
,
$options
[
'collation'
],
'array or object'
);
}
if
(
isset
(
$options
[
'session'
])
&&
!
$options
[
'session'
]
instanceof
Session
)
{
throw
InvalidArgumentException
::
invalidType
(
'"session" option'
,
$options
[
'session'
],
'MongoDB\Driver\Session'
);
}
if
(
isset
(
$options
[
'writeConcern'
])
&&
!
$options
[
'writeConcern'
]
instanceof
WriteConcern
)
{
throw
InvalidArgumentException
::
invalidType
(
'"writeConcern" option'
,
$options
[
'writeConcern'
],
'MongoDB\Driver\WriteConcern'
);
}
...
...
@@ -117,9 +126,29 @@ class Delete implements Executable
$bulk
=
new
Bulk
();
$bulk
->
delete
(
$this
->
filter
,
$deleteOptions
);
$writeConcern
=
isset
(
$this
->
options
[
'writeConcern'
])
?
$this
->
options
[
'writeConcern'
]
:
null
;
$writeResult
=
$server
->
executeBulkWrite
(
$this
->
databaseName
.
'.'
.
$this
->
collectionName
,
$bulk
,
$writeConcern
);
$writeResult
=
$server
->
executeBulkWrite
(
$this
->
databaseName
.
'.'
.
$this
->
collectionName
,
$bulk
,
$this
->
createOptions
());
return
new
DeleteResult
(
$writeResult
);
}
/**
* Create options for executing the bulk write.
*
* @see http://php.net/manual/en/mongodb-driver-server.executebulkwrite.php
* @return array
*/
private
function
createOptions
()
{
$options
=
[];
if
(
isset
(
$this
->
options
[
'session'
]))
{
$options
[
'session'
]
=
$this
->
options
[
'session'
];
}
if
(
isset
(
$this
->
options
[
'writeConcern'
]))
{
$options
[
'writeConcern'
]
=
$this
->
options
[
'writeConcern'
];
}
return
$options
;
}
}
src/Operation/DeleteMany.php
View file @
142d24ec
...
...
@@ -44,6 +44,10 @@ class DeleteMany implements Executable
* This is not supported for server versions < 3.4 and will result in an
* exception at execution time if used.
*
* * session (MongoDB\Driver\Session): Client session.
*
* Sessions are not supported for server versions < 3.6.
*
* * writeConcern (MongoDB\Driver\WriteConcern): Write concern.
*
* @param string $databaseName Database name
...
...
src/Operation/DeleteOne.php
View file @
142d24ec
...
...
@@ -44,6 +44,10 @@ class DeleteOne implements Executable
* This is not supported for server versions < 3.4 and will result in an
* exception at execution time if used.
*
* * session (MongoDB\Driver\Session): Client session.
*
* Sessions are not supported for server versions < 3.6.
*
* * writeConcern (MongoDB\Driver\WriteConcern): Write concern.
*
* @param string $databaseName Database name
...
...
src/Operation/Distinct.php
View file @
142d24ec
...
...
@@ -21,6 +21,7 @@ use MongoDB\Driver\Command;
use
MongoDB\Driver\ReadConcern
;
use
MongoDB\Driver\ReadPreference
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Session
;
use
MongoDB\Driver\Exception\RuntimeException
as
DriverRuntimeException
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\UnexpectedValueException
;
...
...
@@ -64,6 +65,10 @@ class Distinct implements Executable
*
* * readPreference (MongoDB\Driver\ReadPreference): Read preference.
*
* * session (MongoDB\Driver\Session): Client session.
*
* Sessions are not supported for server versions < 3.6.
*
* @param string $databaseName Database name
* @param string $collectionName Collection name
* @param string $fieldName Field for which to return distinct values
...
...
@@ -93,6 +98,10 @@ class Distinct implements Executable
throw
InvalidArgumentException
::
invalidType
(
'"readPreference" option'
,
$options
[
'readPreference'
],
'MongoDB\Driver\ReadPreference'
);
}
if
(
isset
(
$options
[
'session'
])
&&
!
$options
[
'session'
]
instanceof
Session
)
{
throw
InvalidArgumentException
::
invalidType
(
'"session" option'
,
$options
[
'session'
],
'MongoDB\Driver\Session'
);
}
if
(
isset
(
$options
[
'readConcern'
])
&&
$options
[
'readConcern'
]
->
isDefault
())
{
unset
(
$options
[
'readConcern'
]);
}
...
...
@@ -179,6 +188,10 @@ class Distinct implements Executable
$options
[
'readPreference'
]
=
$this
->
options
[
'readPreference'
];
}
if
(
isset
(
$this
->
options
[
'session'
]))
{
$options
[
'session'
]
=
$this
->
options
[
'session'
];
}
return
$options
;
}
}
src/Operation/DropCollection.php
View file @
142d24ec
...
...
@@ -19,6 +19,7 @@ namespace MongoDB\Operation;
use
MongoDB\Driver\Command
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Session
;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Driver\Exception\RuntimeException
as
DriverRuntimeException
;
use
MongoDB\Exception\InvalidArgumentException
;
...
...
@@ -46,6 +47,10 @@ class DropCollection implements Executable
*
* Supported options:
*
* * session (MongoDB\Driver\Session): Client session.
*
* Sessions are not supported for server versions < 3.6.
*
* * typeMap (array): Type map for BSON deserialization. This will be used
* for the returned command result document.
*
...
...
@@ -61,6 +66,10 @@ class DropCollection implements Executable
*/
public
function
__construct
(
$databaseName
,
$collectionName
,
array
$options
=
[])
{
if
(
isset
(
$options
[
'session'
])
&&
!
$options
[
'session'
]
instanceof
Session
)
{
throw
InvalidArgumentException
::
invalidType
(
'"session" option'
,
$options
[
'session'
],
'MongoDB\Driver\Session'
);
}
if
(
isset
(
$options
[
'typeMap'
])
&&
!
is_array
(
$options
[
'typeMap'
]))
{
throw
InvalidArgumentException
::
invalidType
(
'"typeMap" option'
,
$options
[
'typeMap'
],
'array'
);
}
...
...
@@ -126,6 +135,10 @@ class DropCollection implements Executable
{
$options
=
[];
if
(
isset
(
$this
->
options
[
'session'
]))
{
$options
[
'session'
]
=
$this
->
options
[
'session'
];
}
if
(
isset
(
$this
->
options
[
'writeConcern'
]))
{
$options
[
'writeConcern'
]
=
$this
->
options
[
'writeConcern'
];
}
...
...
src/Operation/DropDatabase.php
View file @
142d24ec
...
...
@@ -19,6 +19,7 @@ namespace MongoDB\Operation;
use
MongoDB\Driver\Command
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Session
;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Driver\Exception\RuntimeException
as
DriverRuntimeException
;
use
MongoDB\Exception\InvalidArgumentException
;
...
...
@@ -44,6 +45,10 @@ class DropDatabase implements Executable
*
* Supported options:
*
* * session (MongoDB\Driver\Session): Client session.
*
* Sessions are not supported for server versions < 3.6.
*
* * typeMap (array): Type map for BSON deserialization. This will be used
* for the returned command result document.
*
...
...
@@ -58,6 +63,10 @@ class DropDatabase implements Executable
*/
public
function
__construct
(
$databaseName
,
array
$options
=
[])
{
if
(
isset
(
$options
[
'session'
])
&&
!
$options
[
'session'
]
instanceof
Session
)
{
throw
InvalidArgumentException
::
invalidType
(
'"session" option'
,
$options
[
'session'
],
'MongoDB\Driver\Session'
);
}
if
(
isset
(
$options
[
'typeMap'
])
&&
!
is_array
(
$options
[
'typeMap'
]))
{
throw
InvalidArgumentException
::
invalidType
(
'"typeMap" option'
,
$options
[
'typeMap'
],
'array'
);
}
...
...
@@ -109,6 +118,10 @@ class DropDatabase implements Executable
{
$options
=
[];
if
(
isset
(
$this
->
options
[
'session'
]))
{
$options
[
'session'
]
=
$this
->
options
[
'session'
];
}
if
(
isset
(
$this
->
options
[
'writeConcern'
]))
{
$options
[
'writeConcern'
]
=
$this
->
options
[
'writeConcern'
];
}
...
...
src/Operation/DropIndexes.php
View file @
142d24ec
...
...
@@ -19,6 +19,7 @@ namespace MongoDB\Operation;
use
MongoDB\Driver\Command
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Session
;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Driver\Exception\RuntimeException
as
DriverRuntimeException
;
use
MongoDB\Exception\InvalidArgumentException
;
...
...
@@ -48,6 +49,10 @@ class DropIndexes implements Executable
* * maxTimeMS (integer): The maximum amount of time to allow the query to
* run.
*
* * session (MongoDB\Driver\Session): Client session.
*
* Sessions are not supported for server versions < 3.6.
*
* * typeMap (array): Type map for BSON deserialization. This will be used
* for the returned command result document.
*
...
...
@@ -74,6 +79,10 @@ class DropIndexes implements Executable
throw
InvalidArgumentException
::
invalidType
(
'"maxTimeMS" option'
,
$options
[
'maxTimeMS'
],
'integer'
);
}
if
(
isset
(
$options
[
'session'
])
&&
!
$options
[
'session'
]
instanceof
Session
)
{
throw
InvalidArgumentException
::
invalidType
(
'"session" option'
,
$options
[
'session'
],
'MongoDB\Driver\Session'
);
}
if
(
isset
(
$options
[
'typeMap'
])
&&
!
is_array
(
$options
[
'typeMap'
]))
{
throw
InvalidArgumentException
::
invalidType
(
'"typeMap" option'
,
$options
[
'typeMap'
],
'array'
);
}
...
...
@@ -145,6 +154,10 @@ class DropIndexes implements Executable
{
$options
=
[];
if
(
isset
(
$this
->
options
[
'session'
]))
{
$options
[
'session'
]
=
$this
->
options
[
'session'
];
}
if
(
isset
(
$this
->
options
[
'writeConcern'
]))
{
$options
[
'writeConcern'
]
=
$this
->
options
[
'writeConcern'
];
}
...
...
src/Operation/Find.php
View file @
142d24ec
...
...
@@ -22,6 +22,7 @@ use MongoDB\Driver\Query;
use
MongoDB\Driver\ReadConcern
;
use
MongoDB\Driver\ReadPreference
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Session
;
use
MongoDB\Driver\Exception\RuntimeException
as
DriverRuntimeException
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\UnsupportedException
;
...
...
@@ -114,6 +115,10 @@ class Find implements Executable
* * returnKey (boolean): If true, returns only the index keys in the
* resulting documents.
*
* * session (MongoDB\Driver\Session): Client session.
*
* Sessions are not supported for server versions < 3.6.
*
* * showRecordId (boolean): Determines whether to return the record
* identifier for each document. If true, adds a field $recordId to the
* returned documents.
...
...
@@ -226,6 +231,10 @@ class Find implements Executable
throw
InvalidArgumentException
::
invalidType
(
'"returnKey" option'
,
$options
[
'returnKey'
],
'boolean'
);
}
if
(
isset
(
$options
[
'session'
])
&&
!
$options
[
'session'
]
instanceof
Session
)
{
throw
InvalidArgumentException
::
invalidType
(
'"session" option'
,
$options
[
'session'
],
'MongoDB\Driver\Session'
);
}
if
(
isset
(
$options
[
'showRecordId'
])
&&
!
is_bool
(
$options
[
'showRecordId'
]))
{
throw
InvalidArgumentException
::
invalidType
(
'"showRecordId" option'
,
$options
[
'showRecordId'
],
'boolean'
);
}
...
...
@@ -275,9 +284,7 @@ class Find implements Executable
throw
UnsupportedException
::
readConcernNotSupported
();
}
$readPreference
=
isset
(
$this
->
options
[
'readPreference'
])
?
$this
->
options
[
'readPreference'
]
:
null
;
$cursor
=
$server
->
executeQuery
(
$this
->
databaseName
.
'.'
.
$this
->
collectionName
,
$this
->
createQuery
(),
$readPreference
);
$cursor
=
$server
->
executeQuery
(
$this
->
databaseName
.
'.'
.
$this
->
collectionName
,
$this
->
createQuery
(),
$this
->
createOptions
());
if
(
isset
(
$this
->
options
[
'typeMap'
]))
{
$cursor
->
setTypeMap
(
$this
->
options
[
'typeMap'
]);
...
...
@@ -286,6 +293,27 @@ class Find implements Executable
return
$cursor
;
}
/**
* Create options for executing the command.
*
* @see http://php.net/manual/en/mongodb-driver-server.executequery.php
* @return array
*/
private
function
createOptions
()
{
$options
=
[];
if
(
isset
(
$this
->
options
[
'readPreference'
]))
{
$options
[
'readPreference'
]
=
$this
->
options
[
'readPreference'
];
}
if
(
isset
(
$this
->
options
[
'session'
]))
{
$options
[
'session'
]
=
$this
->
options
[
'session'
];
}
return
$options
;
}
/**
* Create the find query.
*
...
...
src/Operation/FindAndModify.php
View file @
142d24ec
...
...
@@ -19,6 +19,7 @@ namespace MongoDB\Operation;
use
MongoDB\Driver\Command
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Session
;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Driver\Exception\RuntimeException
as
DriverRuntimeException
;
use
MongoDB\Exception\InvalidArgumentException
;
...
...
@@ -82,6 +83,10 @@ class FindAndModify implements Executable
* * remove (boolean): When true, removes the matched document. This option
* cannot be true if the update option is set. The default is false.
*
* * session (MongoDB\Driver\Session): Client session.
*
* Sessions are not supported for server versions < 3.6.
*
* * sort (document): Determines which document the operation modifies if
* the query selects multiple documents.
*
...
...
@@ -144,6 +149,10 @@ class FindAndModify implements Executable
throw
InvalidArgumentException
::
invalidType
(
'"remove" option'
,
$options
[
'remove'
],
'boolean'
);
}
if
(
isset
(
$options
[
'session'
])
&&
!
$options
[
'session'
]
instanceof
Session
)
{
throw
InvalidArgumentException
::
invalidType
(
'"session" option'
,
$options
[
'session'
],
'MongoDB\Driver\Session'
);
}
if
(
isset
(
$options
[
'sort'
])
&&
!
is_array
(
$options
[
'sort'
])
&&
!
is_object
(
$options
[
'sort'
]))
{
throw
InvalidArgumentException
::
invalidType
(
'"sort" option'
,
$options
[
'sort'
],
'array or object'
);
}
...
...
@@ -278,6 +287,10 @@ class FindAndModify implements Executable
{
$options
=
[];
if
(
isset
(
$this
->
options
[
'session'
]))
{
$options
[
'session'
]
=
$this
->
options
[
'session'
];
}
if
(
isset
(
$this
->
options
[
'writeConcern'
]))
{
$options
[
'writeConcern'
]
=
$this
->
options
[
'writeConcern'
];
}
...
...
src/Operation/FindOne.php
View file @
142d24ec
...
...
@@ -78,6 +78,10 @@ class FindOne implements Executable
* * returnKey (boolean): If true, returns only the index keys in the
* resulting documents.
*
* * session (MongoDB\Driver\Session): Client session.
*
* Sessions are not supported for server versions < 3.6.
*
* * showRecordId (boolean): Determines whether to return the record
* identifier for each document. If true, adds a field $recordId to the
* returned documents.
...
...
src/Operation/FindOneAndDelete.php
View file @
142d24ec
...
...
@@ -49,6 +49,10 @@ class FindOneAndDelete implements Executable
* * projection (document): Limits the fields to return for the matching
* document.
*
* * session (MongoDB\Driver\Session): Client session.
*
* Sessions are not supported for server versions < 3.6.
*
* * sort (document): Determines which document the operation modifies if
* the query selects multiple documents.
*
...
...
src/Operation/FindOneAndReplace.php
View file @
142d24ec
...
...
@@ -64,6 +64,10 @@ class FindOneAndReplace implements Executable
* FindOneAndReplace::RETURN_DOCUMENT_AFTER. The default is
* FindOneAndReplace::RETURN_DOCUMENT_BEFORE.
*
* * session (MongoDB\Driver\Session): Client session.
*
* Sessions are not supported for server versions < 3.6.
*
* * sort (document): Determines which document the operation modifies if
* the query selects multiple documents.
*
...
...
src/Operation/FindOneAndUpdate.php
View file @
142d24ec
...
...
@@ -67,6 +67,10 @@ class FindOneAndUpdate implements Executable
* FindOneAndUpdate::RETURN_DOCUMENT_AFTER. The default is
* FindOneAndUpdate::RETURN_DOCUMENT_BEFORE.
*
* * session (MongoDB\Driver\Session): Client session.
*
* Sessions are not supported for server versions < 3.6.
*
* * sort (document): Determines which document the operation modifies if
* the query selects multiple documents.
*
...
...
src/Operation/InsertMany.php
View file @
142d24ec
...
...
@@ -20,6 +20,7 @@ namespace MongoDB\Operation;
use
MongoDB\InsertManyResult
;
use
MongoDB\Driver\BulkWrite
as
Bulk
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Session
;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Driver\Exception\RuntimeException
as
DriverRuntimeException
;
use
MongoDB\Exception\InvalidArgumentException
;
...
...
@@ -55,6 +56,10 @@ class InsertMany implements Executable
* performing the remaining writes. If false, when a write fails,
* continue with the remaining writes, if any. The default is true.
*
* * session (MongoDB\Driver\Session): Client session.
*
* Sessions are not supported for server versions < 3.6.
*
* * writeConcern (MongoDB\Driver\WriteConcern): Write concern.
*
* @param string $databaseName Database name
...
...
@@ -93,6 +98,10 @@ class InsertMany implements Executable
throw
InvalidArgumentException
::
invalidType
(
'"ordered" option'
,
$options
[
'ordered'
],
'boolean'
);
}
if
(
isset
(
$options
[
'session'
])
&&
!
$options
[
'session'
]
instanceof
Session
)
{
throw
InvalidArgumentException
::
invalidType
(
'"session" option'
,
$options
[
'session'
],
'MongoDB\Driver\Session'
);
}
if
(
isset
(
$options
[
'writeConcern'
])
&&
!
$options
[
'writeConcern'
]
instanceof
WriteConcern
)
{
throw
InvalidArgumentException
::
invalidType
(
'"writeConcern" option'
,
$options
[
'writeConcern'
],
'MongoDB\Driver\WriteConcern'
);
}
...
...
@@ -130,9 +139,29 @@ class InsertMany implements Executable
$insertedIds
[
$i
]
=
$bulk
->
insert
(
$document
);
}
$writeConcern
=
isset
(
$this
->
options
[
'writeConcern'
])
?
$this
->
options
[
'writeConcern'
]
:
null
;
$writeResult
=
$server
->
executeBulkWrite
(
$this
->
databaseName
.
'.'
.
$this
->
collectionName
,
$bulk
,
$writeConcern
);
$writeResult
=
$server
->
executeBulkWrite
(
$this
->
databaseName
.
'.'
.
$this
->
collectionName
,
$bulk
,
$this
->
createOptions
());
return
new
InsertManyResult
(
$writeResult
,
$insertedIds
);
}
/**
* Create options for executing the bulk write.
*
* @see http://php.net/manual/en/mongodb-driver-server.executebulkwrite.php
* @return array
*/
private
function
createOptions
()
{
$options
=
[];
if
(
isset
(
$this
->
options
[
'session'
]))
{
$options
[
'session'
]
=
$this
->
options
[
'session'
];
}
if
(
isset
(
$this
->
options
[
'writeConcern'
]))
{
$options
[
'writeConcern'
]
=
$this
->
options
[
'writeConcern'
];
}
return
$options
;
}
}
src/Operation/InsertOne.php
View file @
142d24ec
...
...
@@ -20,6 +20,7 @@ namespace MongoDB\Operation;
use
MongoDB\InsertOneResult
;
use
MongoDB\Driver\BulkWrite
as
Bulk
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Session
;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Driver\Exception\RuntimeException
as
DriverRuntimeException
;
use
MongoDB\Exception\InvalidArgumentException
;
...
...
@@ -51,6 +52,10 @@ class InsertOne implements Executable
* For servers < 3.2, this option is ignored as document level validation
* is not available.
*
* * session (MongoDB\Driver\Session): Client session.
*
* Sessions are not supported for server versions < 3.6.
*
* * writeConcern (MongoDB\Driver\WriteConcern): Write concern.
*
* @param string $databaseName Database name
...
...
@@ -69,6 +74,10 @@ class InsertOne implements Executable
throw
InvalidArgumentException
::
invalidType
(
'"bypassDocumentValidation" option'
,
$options
[
'bypassDocumentValidation'
],
'boolean'
);
}
if
(
isset
(
$options
[
'session'
])
&&
!
$options
[
'session'
]
instanceof
Session
)
{
throw
InvalidArgumentException
::
invalidType
(
'"session" option'
,
$options
[
'session'
],
'MongoDB\Driver\Session'
);
}
if
(
isset
(
$options
[
'writeConcern'
])
&&
!
$options
[
'writeConcern'
]
instanceof
WriteConcern
)
{
throw
InvalidArgumentException
::
invalidType
(
'"writeConcern" option'
,
$options
[
'writeConcern'
],
'MongoDB\Driver\WriteConcern'
);
}
...
...
@@ -102,9 +111,29 @@ class InsertOne implements Executable
$bulk
=
new
Bulk
(
$options
);
$insertedId
=
$bulk
->
insert
(
$this
->
document
);
$writeConcern
=
isset
(
$this
->
options
[
'writeConcern'
])
?
$this
->
options
[
'writeConcern'
]
:
null
;
$writeResult
=
$server
->
executeBulkWrite
(
$this
->
databaseName
.
'.'
.
$this
->
collectionName
,
$bulk
,
$writeConcern
);
$writeResult
=
$server
->
executeBulkWrite
(
$this
->
databaseName
.
'.'
.
$this
->
collectionName
,
$bulk
,
$this
->
createOptions
());
return
new
InsertOneResult
(
$writeResult
,
$insertedId
);
}
/**
* Create options for executing the bulk write.
*
* @see http://php.net/manual/en/mongodb-driver-server.executebulkwrite.php
* @return array
*/
private
function
createOptions
()
{
$options
=
[];
if
(
isset
(
$this
->
options
[
'session'
]))
{
$options
[
'session'
]
=
$this
->
options
[
'session'
];
}
if
(
isset
(
$this
->
options
[
'writeConcern'
]))
{
$options
[
'writeConcern'
]
=
$this
->
options
[
'writeConcern'
];
}
return
$options
;
}
}
src/Operation/ListCollections.php
View file @
142d24ec
...
...
@@ -20,6 +20,7 @@ namespace MongoDB\Operation;
use
MongoDB\Driver\Command
;
use
MongoDB\Driver\Query
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Session
;
use
MongoDB\Driver\Exception\RuntimeException
as
DriverRuntimeException
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Model\CachingIterator
;
...
...
@@ -51,6 +52,10 @@ class ListCollections implements Executable
* * maxTimeMS (integer): The maximum amount of time to allow the query to
* run.
*
* * session (MongoDB\Driver\Session): Client session.
*
* Sessions are not supported for server versions < 3.6.
*
* @param string $databaseName Database name
* @param array $options Command options
* @throws InvalidArgumentException for parameter/option parsing errors
...
...
@@ -65,6 +70,10 @@ class ListCollections implements Executable
throw
InvalidArgumentException
::
invalidType
(
'"maxTimeMS" option'
,
$options
[
'maxTimeMS'
],
'integer'
);
}
if
(
isset
(
$options
[
'session'
])
&&
!
$options
[
'session'
]
instanceof
Session
)
{
throw
InvalidArgumentException
::
invalidType
(
'"session" option'
,
$options
[
'session'
],
'MongoDB\Driver\Session'
);
}
$this
->
databaseName
=
(
string
)
$databaseName
;
$this
->
options
=
$options
;
}
...
...
@@ -85,6 +94,26 @@ class ListCollections implements Executable
:
$this
->
executeLegacy
(
$server
);
}
/**
* Create options for executing the command.
*
* Note: read preference is intentionally omitted, as the spec requires that
* the command be executed on the primary.
*
* @see http://php.net/manual/en/mongodb-driver-server.executecommand.php
* @return array
*/
private
function
createOptions
()
{
$options
=
[];
if
(
isset
(
$this
->
options
[
'session'
]))
{
$options
[
'session'
]
=
$this
->
options
[
'session'
];
}
return
$options
;
}
/**
* Returns information for all collections in this database using the
* listCollections command.
...
...
@@ -105,7 +134,7 @@ class ListCollections implements Executable
$cmd
[
'maxTimeMS'
]
=
$this
->
options
[
'maxTimeMS'
];
}
$cursor
=
$server
->
executeCommand
(
$this
->
databaseName
,
new
Command
(
$cmd
));
$cursor
=
$server
->
executeCommand
(
$this
->
databaseName
,
new
Command
(
$cmd
)
,
$this
->
createOptions
()
);
$cursor
->
setTypeMap
([
'root'
=>
'array'
,
'document'
=>
'array'
]);
return
new
CollectionInfoCommandIterator
(
new
CachingIterator
(
$cursor
));
...
...
src/Operation/ListDatabases.php
View file @
142d24ec
...
...
@@ -19,6 +19,7 @@ namespace MongoDB\Operation;
use
MongoDB\Driver\Command
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Session
;
use
MongoDB\Driver\Exception\RuntimeException
as
DriverRuntimeException
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\UnexpectedValueException
;
...
...
@@ -44,6 +45,10 @@ class ListDatabases implements Executable
* * maxTimeMS (integer): The maximum amount of time to allow the query to
* run.
*
* * session (MongoDB\Driver\Session): Client session.
*
* Sessions are not supported for server versions < 3.6.
*
* @param array $options Command options
* @throws InvalidArgumentException for parameter/option parsing errors
*/
...
...
@@ -53,6 +58,10 @@ class ListDatabases implements Executable
throw
InvalidArgumentException
::
invalidType
(
'"maxTimeMS" option'
,
$options
[
'maxTimeMS'
],
'integer'
);
}
if
(
isset
(
$options
[
'session'
])
&&
!
$options
[
'session'
]
instanceof
Session
)
{
throw
InvalidArgumentException
::
invalidType
(
'"session" option'
,
$options
[
'session'
],
'MongoDB\Driver\Session'
);
}
$this
->
options
=
$options
;
}
...
...
@@ -73,7 +82,7 @@ class ListDatabases implements Executable
$cmd
[
'maxTimeMS'
]
=
$this
->
options
[
'maxTimeMS'
];
}
$cursor
=
$server
->
executeCommand
(
'admin'
,
new
Command
(
$cmd
));
$cursor
=
$server
->
executeCommand
(
'admin'
,
new
Command
(
$cmd
)
,
$this
->
createOptions
()
);
$cursor
->
setTypeMap
([
'root'
=>
'array'
,
'document'
=>
'array'
]);
$result
=
current
(
$cursor
->
toArray
());
...
...
@@ -89,4 +98,24 @@ class ListDatabases implements Executable
*/
return
new
DatabaseInfoLegacyIterator
(
$result
[
'databases'
]);
}
/**
* Create options for executing the command.
*
* Note: read preference is intentionally omitted, as the spec requires that
* the command be executed on the primary.
*
* @see http://php.net/manual/en/mongodb-driver-server.executecommand.php
* @return array
*/
private
function
createOptions
()
{
$options
=
[];
if
(
isset
(
$this
->
options
[
'session'
]))
{
$options
[
'session'
]
=
$this
->
options
[
'session'
];
}
return
$options
;
}
}
src/Operation/ListIndexes.php
View file @
142d24ec
...
...
@@ -20,6 +20,7 @@ namespace MongoDB\Operation;
use
MongoDB\Driver\Command
;
use
MongoDB\Driver\Query
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Session
;
use
MongoDB\Driver\Exception\RuntimeException
as
DriverRuntimeException
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Model\CachingIterator
;
...
...
@@ -52,6 +53,10 @@ class ListIndexes implements Executable
* * maxTimeMS (integer): The maximum amount of time to allow the query to
* run.
*
* * session (MongoDB\Driver\Session): Client session.
*
* Sessions are not supported for server versions < 3.6.
*
* @param string $databaseName Database name
* @param string $collectionName Collection name
* @param array $options Command options
...
...
@@ -63,6 +68,10 @@ class ListIndexes implements Executable
throw
InvalidArgumentException
::
invalidType
(
'"maxTimeMS" option'
,
$options
[
'maxTimeMS'
],
'integer'
);
}
if
(
isset
(
$options
[
'session'
])
&&
!
$options
[
'session'
]
instanceof
Session
)
{
throw
InvalidArgumentException
::
invalidType
(
'"session" option'
,
$options
[
'session'
],
'MongoDB\Driver\Session'
);
}
$this
->
databaseName
=
(
string
)
$databaseName
;
$this
->
collectionName
=
(
string
)
$collectionName
;
$this
->
options
=
$options
;
...
...
@@ -83,6 +92,26 @@ class ListIndexes implements Executable
:
$this
->
executeLegacy
(
$server
);
}
/**
* Create options for executing the command.
*
* Note: read preference is intentionally omitted, as the spec requires that
* the command be executed on the primary.
*
* @see http://php.net/manual/en/mongodb-driver-server.executecommand.php
* @return array
*/
private
function
createOptions
()
{
$options
=
[];
if
(
isset
(
$this
->
options
[
'session'
]))
{
$options
[
'session'
]
=
$this
->
options
[
'session'
];
}
return
$options
;
}
/**
* Returns information for all indexes for this collection using the
* listIndexes command.
...
...
@@ -100,7 +129,7 @@ class ListIndexes implements Executable
}
try
{
$cursor
=
$server
->
executeCommand
(
$this
->
databaseName
,
new
Command
(
$cmd
));
$cursor
=
$server
->
executeCommand
(
$this
->
databaseName
,
new
Command
(
$cmd
)
,
$this
->
createOptions
()
);
}
catch
(
DriverRuntimeException
$e
)
{
/* The server may return an error if the collection does not exist.
* Check for possible error codes (see: SERVER-20463) and return an
...
...
src/Operation/MapReduce.php
View file @
142d24ec
...
...
@@ -22,6 +22,7 @@ use MongoDB\Driver\Command;
use
MongoDB\Driver\ReadConcern
;
use
MongoDB\Driver\ReadPreference
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Session
;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Driver\Exception\RuntimeException
as
DriverRuntimeException
;
use
MongoDB\Exception\InvalidArgumentException
;
...
...
@@ -112,6 +113,10 @@ class MapReduce implements Executable
* * scope (document): Specifies global variables that are accessible in
* the map, reduce and finalize functions.
*
* * session (MongoDB\Driver\Session): Client session.
*
* Sessions are not supported for server versions < 3.6.
*
* * sort (document): Sorts the input documents. This option is useful for
* optimization. For example, specify the sort key to be the same as the
* emit key so that there are fewer reduce operations. The sort key must
...
...
@@ -183,6 +188,10 @@ class MapReduce implements Executable
throw
InvalidArgumentException
::
invalidType
(
'"scope" option'
,
$options
[
'scope'
],
'array or object'
);
}
if
(
isset
(
$options
[
'session'
])
&&
!
$options
[
'session'
]
instanceof
Session
)
{
throw
InvalidArgumentException
::
invalidType
(
'"session" option'
,
$options
[
'session'
],
'MongoDB\Driver\Session'
);
}
if
(
isset
(
$options
[
'sort'
])
&&
!
is_array
(
$options
[
'sort'
])
&&
!
is_object
(
$options
[
'sort'
]))
{
throw
InvalidArgumentException
::
invalidType
(
'"sort" option'
,
$options
[
'sort'
],
'array or object'
);
}
...
...
@@ -347,6 +356,10 @@ class MapReduce implements Executable
$options
[
'readPreference'
]
=
$this
->
options
[
'readPreference'
];
}
if
(
isset
(
$this
->
options
[
'session'
]))
{
$options
[
'session'
]
=
$this
->
options
[
'session'
];
}
if
(
$hasOutputCollection
&&
isset
(
$this
->
options
[
'writeConcern'
]))
{
$options
[
'writeConcern'
]
=
$this
->
options
[
'writeConcern'
];
}
...
...
src/Operation/ReplaceOne.php
View file @
142d24ec
...
...
@@ -50,6 +50,10 @@ class ReplaceOne implements Executable
* This is not supported for server versions < 3.4 and will result in an
* exception at execution time if used.
*
* * session (MongoDB\Driver\Session): Client session.
*
* Sessions are not supported for server versions < 3.6.
*
* * upsert (boolean): When true, a new document is created if no document
* matches the query. The default is false.
*
...
...
src/Operation/Update.php
View file @
142d24ec
...
...
@@ -20,6 +20,7 @@ namespace MongoDB\Operation;
use
MongoDB\UpdateResult
;
use
MongoDB\Driver\BulkWrite
as
Bulk
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Session
;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Driver\Exception\RuntimeException
as
DriverRuntimeException
;
use
MongoDB\Exception\InvalidArgumentException
;
...
...
@@ -72,6 +73,10 @@ class Update implements Executable
* This option cannot be true if the $update argument is a replacement
* document (i.e. contains no update operators). The default is false.
*
* * session (MongoDB\Driver\Session): Client session.
*
* Sessions are not supported for server versions < 3.6.
*
* * upsert (boolean): When true, a new document is created if no document
* matches the query. The default is false.
*
...
...
@@ -120,6 +125,10 @@ class Update implements Executable
throw
new
InvalidArgumentException
(
'"multi" option cannot be true if $update is a replacement document'
);
}
if
(
isset
(
$options
[
'session'
])
&&
!
$options
[
'session'
]
instanceof
Session
)
{
throw
InvalidArgumentException
::
invalidType
(
'"session" option'
,
$options
[
'session'
],
'MongoDB\Driver\Session'
);
}
if
(
!
is_bool
(
$options
[
'upsert'
]))
{
throw
InvalidArgumentException
::
invalidType
(
'"upsert" option'
,
$options
[
'upsert'
],
'boolean'
);
}
...
...
@@ -180,9 +189,29 @@ class Update implements Executable
$bulk
=
new
Bulk
(
$bulkOptions
);
$bulk
->
update
(
$this
->
filter
,
$this
->
update
,
$updateOptions
);
$writeConcern
=
isset
(
$this
->
options
[
'writeConcern'
])
?
$this
->
options
[
'writeConcern'
]
:
null
;
$writeResult
=
$server
->
executeBulkWrite
(
$this
->
databaseName
.
'.'
.
$this
->
collectionName
,
$bulk
,
$writeConcern
);
$writeResult
=
$server
->
executeBulkWrite
(
$this
->
databaseName
.
'.'
.
$this
->
collectionName
,
$bulk
,
$this
->
createOptions
());
return
new
UpdateResult
(
$writeResult
);
}
/**
* Create options for executing the bulk write.
*
* @see http://php.net/manual/en/mongodb-driver-server.executebulkwrite.php
* @return array
*/
private
function
createOptions
()
{
$options
=
[];
if
(
isset
(
$this
->
options
[
'session'
]))
{
$options
[
'session'
]
=
$this
->
options
[
'session'
];
}
if
(
isset
(
$this
->
options
[
'writeConcern'
]))
{
$options
[
'writeConcern'
]
=
$this
->
options
[
'writeConcern'
];
}
return
$options
;
}
}
src/Operation/UpdateMany.php
View file @
142d24ec
...
...
@@ -56,6 +56,10 @@ class UpdateMany implements Executable
* This is not supported for server versions < 3.4 and will result in an
* exception at execution time if used.
*
* * session (MongoDB\Driver\Session): Client session.
*
* Sessions are not supported for server versions < 3.6.
*
* * upsert (boolean): When true, a new document is created if no document
* matches the query. The default is false.
*
...
...
src/Operation/UpdateOne.php
View file @
142d24ec
...
...
@@ -56,6 +56,10 @@ class UpdateOne implements Executable
* This is not supported for server versions < 3.4 and will result in an
* exception at execution time if used.
*
* * session (MongoDB\Driver\Session): Client session.
*
* Sessions are not supported for server versions < 3.6.
*
* * upsert (boolean): When true, a new document is created if no document
* matches the query. The default is false.
*
...
...
src/Operation/Watch.php
View file @
142d24ec
...
...
@@ -23,6 +23,7 @@ use MongoDB\Driver\Manager;
use
MongoDB\Driver\ReadConcern
;
use
MongoDB\Driver\ReadPreference
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Session
;
use
MongoDB\Driver\Exception\RuntimeException
as
DriverRuntimeException
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\UnexpectedValueException
;
...
...
@@ -65,6 +66,10 @@ class Watch implements Executable
* Insert and replace operations always include the "fullDocument" field
* and delete operations omit the field as the document no longer exists.
*
* * session (MongoDB\Driver\Session): Client session.
*
* Sessions are not supported for server versions < 3.6.
*
* * maxAwaitTimeMS (integer): The maximum amount of time for the server to
* wait on new documents to satisfy a change stream query.
*
...
...
tests/Operation/AggregateFunctionalTest.php
View file @
142d24ec
...
...
@@ -72,6 +72,29 @@ class AggregateFunctionalTest extends FunctionalTestCase
$operation
->
execute
(
$this
->
getPrimaryServer
());
}
public
function
testSessionOption
()
{
if
(
version_compare
(
$this
->
getServerVersion
(),
'3.6.0'
,
'<'
))
{
$this
->
markTestSkipped
(
'Sessions are not supported'
);
}
(
new
CommandObserver
)
->
observe
(
function
()
{
$operation
=
new
Aggregate
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[],
[
'session'
=>
$this
->
createSession
()]
);
$operation
->
execute
(
$this
->
getPrimaryServer
());
},
function
(
stdClass
$command
)
{
$this
->
assertObjectHasAttribute
(
'lsid'
,
$command
);
}
);
}
/**
* @dataProvider provideTypeMapOptionsAndExpectedDocuments
*/
...
...
tests/Operation/AggregateTest.php
View file @
142d24ec
...
...
@@ -64,6 +64,10 @@ class AggregateTest extends TestCase
$options
[][]
=
[
'readPreference'
=>
$value
];
}
foreach
(
$this
->
getInvalidSessionValues
()
as
$value
)
{
$options
[][]
=
[
'session'
=>
$value
];
}
foreach
(
$this
->
getInvalidArrayValues
()
as
$value
)
{
$options
[][]
=
[
'typeMap'
=>
$value
];
}
...
...
tests/Operation/BulkWriteFunctionalTest.php
View file @
142d24ec
...
...
@@ -8,6 +8,8 @@ use MongoDB\Driver\BulkWrite as Bulk;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Model\BSONDocument
;
use
MongoDB\Operation\BulkWrite
;
use
MongoDB\Tests\CommandObserver
;
use
stdClass
;
class
BulkWriteFunctionalTest
extends
FunctionalTestCase
{
...
...
@@ -286,6 +288,29 @@ class BulkWriteFunctionalTest extends FunctionalTestCase
]);
}
public
function
testSessionOption
()
{
if
(
version_compare
(
$this
->
getServerVersion
(),
'3.6.0'
,
'<'
))
{
$this
->
markTestSkipped
(
'Sessions are not supported'
);
}
(
new
CommandObserver
)
->
observe
(
function
()
{
$operation
=
new
BulkWrite
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[[
'insertOne'
=>
[[
'_id'
=>
1
]]]],
[
'session'
=>
$this
->
createSession
()]
);
$operation
->
execute
(
$this
->
getPrimaryServer
());
},
function
(
stdClass
$command
)
{
$this
->
assertObjectHasAttribute
(
'lsid'
,
$command
);
}
);
}
/**
* Create data fixtures.
*
...
...
tests/Operation/BulkWriteTest.php
View file @
142d24ec
...
...
@@ -447,6 +447,10 @@ class BulkWriteTest extends TestCase
$options
[][]
=
[
'ordered'
=>
$value
];
}
foreach
(
$this
->
getInvalidSessionValues
()
as
$value
)
{
$options
[][]
=
[
'session'
=>
$value
];
}
foreach
(
$this
->
getInvalidWriteConcernValues
()
as
$value
)
{
$options
[][]
=
[
'writeConcern'
=>
$value
];
}
...
...
tests/Operation/CountFunctionalTest.php
View file @
142d24ec
...
...
@@ -69,4 +69,27 @@ class CountFunctionalTest extends FunctionalTestCase
$this
->
assertEquals
(
3
,
$operation
->
execute
(
$this
->
getPrimaryServer
()));
}
}
public
function
testSessionOption
()
{
if
(
version_compare
(
$this
->
getServerVersion
(),
'3.6.0'
,
'<'
))
{
$this
->
markTestSkipped
(
'Sessions are not supported'
);
}
(
new
CommandObserver
)
->
observe
(
function
()
{
$operation
=
new
Count
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[],
[
'session'
=>
$this
->
createSession
()]
);
$operation
->
execute
(
$this
->
getPrimaryServer
());
},
function
(
stdClass
$command
)
{
$this
->
assertObjectHasAttribute
(
'lsid'
,
$command
);
}
);
}
}
tests/Operation/CountTest.php
View file @
142d24ec
...
...
@@ -52,6 +52,10 @@ class CountTest extends TestCase
$options
[][]
=
[
'readPreference'
=>
$value
];
}
foreach
(
$this
->
getInvalidSessionValues
()
as
$value
)
{
$options
[][]
=
[
'session'
=>
$value
];
}
foreach
(
$this
->
getInvalidIntegerValues
()
as
$value
)
{
$options
[][]
=
[
'skip'
=>
$value
];
}
...
...
tests/Operation/CreateCollectionFunctionalTest.php
View file @
142d24ec
...
...
@@ -25,4 +25,26 @@ class CreateCollectionFunctionalTest extends FunctionalTestCase
}
);
}
public
function
testSessionOption
()
{
if
(
version_compare
(
$this
->
getServerVersion
(),
'3.6.0'
,
'<'
))
{
$this
->
markTestSkipped
(
'Sessions are not supported'
);
}
(
new
CommandObserver
)
->
observe
(
function
()
{
$operation
=
new
CreateCollection
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[
'session'
=>
$this
->
createSession
()]
);
$operation
->
execute
(
$this
->
getPrimaryServer
());
},
function
(
stdClass
$command
)
{
$this
->
assertObjectHasAttribute
(
'lsid'
,
$command
);
}
);
}
}
tests/Operation/CreateCollectionTest.php
View file @
142d24ec
...
...
@@ -47,6 +47,10 @@ class CreateCollectionTest extends TestCase
$options
[][]
=
[
'maxTimeMS'
=>
$value
];
}
foreach
(
$this
->
getInvalidSessionValues
()
as
$value
)
{
$options
[][]
=
[
'session'
=>
$value
];
}
foreach
(
$this
->
getInvalidIntegerValues
()
as
$value
)
{
$options
[][]
=
[
'size'
=>
$value
];
}
...
...
tests/Operation/CreateIndexesFunctionalTest.php
View file @
142d24ec
...
...
@@ -146,6 +146,29 @@ class CreateIndexesFunctionalTest extends FunctionalTestCase
);
}
public
function
testSessionOption
()
{
if
(
version_compare
(
$this
->
getServerVersion
(),
'3.6.0'
,
'<'
))
{
$this
->
markTestSkipped
(
'Sessions are not supported'
);
}
(
new
CommandObserver
)
->
observe
(
function
()
{
$operation
=
new
CreateIndexes
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[[
'key'
=>
[
'x'
=>
1
]]],
[
'session'
=>
$this
->
createSession
()]
);
$operation
->
execute
(
$this
->
getPrimaryServer
());
},
function
(
stdClass
$command
)
{
$this
->
assertObjectHasAttribute
(
'lsid'
,
$command
);
}
);
}
/**
* Asserts that an index with the given name exists for the collection.
*
...
...
tests/Operation/CreateIndexesTest.php
View file @
142d24ec
...
...
@@ -32,6 +32,10 @@ class CreateIndexesTest extends TestCase
$options
[][]
=
[
'maxTimeMS'
=>
$value
];
}
foreach
(
$this
->
getInvalidSessionValues
()
as
$value
)
{
$options
[][]
=
[
'session'
=>
$value
];
}
foreach
(
$this
->
getInvalidWriteConcernValues
()
as
$value
)
{
$options
[][]
=
[
'writeConcern'
=>
$value
];
}
...
...
tests/Operation/DatabaseCommandFunctionalTest.php
0 → 100644
View file @
142d24ec
<?php
namespace
MongoDB\Tests\Operation
;
use
MongoDB\Operation\DatabaseCommand
;
use
MongoDB\Tests\CommandObserver
;
use
stdClass
;
class
DatabaseCommandFunctionalTest
extends
FunctionalTestCase
{
public
function
testSessionOption
()
{
if
(
version_compare
(
$this
->
getServerVersion
(),
'3.6.0'
,
'<'
))
{
$this
->
markTestSkipped
(
'Sessions are not supported'
);
}
(
new
CommandObserver
)
->
observe
(
function
()
{
$operation
=
new
DatabaseCommand
(
$this
->
getDatabaseName
(),
[
'ping'
=>
1
],
[
'session'
=>
$this
->
createSession
()]
);
$operation
->
execute
(
$this
->
getPrimaryServer
());
},
function
(
stdClass
$command
)
{
$this
->
assertObjectHasAttribute
(
'lsid'
,
$command
);
}
);
}
}
tests/Operation/DatabaseCommandTest.php
View file @
142d24ec
...
...
@@ -32,6 +32,10 @@ class DatabaseCommandTest extends TestCase
$options
[][]
=
[
'readPreference'
=>
$value
];
}
foreach
(
$this
->
getInvalidSessionValues
()
as
$value
)
{
$options
[][]
=
[
'session'
=>
$value
];
}
foreach
(
$this
->
getInvalidArrayValues
()
as
$value
)
{
$options
[][]
=
[
'typeMap'
=>
$value
];
}
...
...
tests/Operation/DeleteFunctionalTest.php
View file @
142d24ec
...
...
@@ -7,6 +7,8 @@ use MongoDB\Collection;
use
MongoDB\Driver\BulkWrite
;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Operation\Delete
;
use
MongoDB\Tests\CommandObserver
;
use
stdClass
;
class
DeleteFunctionalTest
extends
FunctionalTestCase
{
...
...
@@ -58,6 +60,30 @@ class DeleteFunctionalTest extends FunctionalTestCase
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
public
function
testSessionOption
()
{
if
(
version_compare
(
$this
->
getServerVersion
(),
'3.6.0'
,
'<'
))
{
$this
->
markTestSkipped
(
'Sessions are not supported'
);
}
(
new
CommandObserver
)
->
observe
(
function
()
{
$operation
=
new
Delete
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[],
0
,
[
'session'
=>
$this
->
createSession
()]
);
$operation
->
execute
(
$this
->
getPrimaryServer
());
},
function
(
stdClass
$command
)
{
$this
->
assertObjectHasAttribute
(
'lsid'
,
$command
);
}
);
}
public
function
testUnacknowledgedWriteConcern
()
{
$filter
=
[
'_id'
=>
1
];
...
...
tests/Operation/DeleteTest.php
View file @
142d24ec
...
...
@@ -47,6 +47,10 @@ class DeleteTest extends TestCase
$options
[][]
=
[
'collation'
=>
$value
];
}
foreach
(
$this
->
getInvalidSessionValues
()
as
$value
)
{
$options
[][]
=
[
'session'
=>
$value
];
}
foreach
(
$this
->
getInvalidWriteConcernValues
()
as
$value
)
{
$options
[][]
=
[
'writeConcern'
=>
$value
];
}
...
...
tests/Operation/DistinctFunctionalTest.php
View file @
142d24ec
...
...
@@ -27,4 +27,28 @@ class DistinctFunctionalTest extends FunctionalTestCase
}
);
}
public
function
testSessionOption
()
{
if
(
version_compare
(
$this
->
getServerVersion
(),
'3.6.0'
,
'<'
))
{
$this
->
markTestSkipped
(
'Sessions are not supported'
);
}
(
new
CommandObserver
)
->
observe
(
function
()
{
$operation
=
new
Distinct
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
'x'
,
[],
[
'session'
=>
$this
->
createSession
()]
);
$operation
->
execute
(
$this
->
getPrimaryServer
());
},
function
(
stdClass
$command
)
{
$this
->
assertObjectHasAttribute
(
'lsid'
,
$command
);
}
);
}
}
tests/Operation/DistinctTest.php
View file @
142d24ec
...
...
@@ -44,6 +44,10 @@ class DistinctTest extends TestCase
$options
[][]
=
[
'readPreference'
=>
$value
];
}
foreach
(
$this
->
getInvalidSessionValues
()
as
$value
)
{
$options
[][]
=
[
'session'
=>
$value
];
}
return
$options
;
}
}
tests/Operation/DropCollectionFunctionalTest.php
View file @
142d24ec
...
...
@@ -53,6 +53,28 @@ class DropCollectionFunctionalTest extends FunctionalTestCase
$operation
->
execute
(
$this
->
getPrimaryServer
());
}
public
function
testSessionOption
()
{
if
(
version_compare
(
$this
->
getServerVersion
(),
'3.6.0'
,
'<'
))
{
$this
->
markTestSkipped
(
'Sessions are not supported'
);
}
(
new
CommandObserver
)
->
observe
(
function
()
{
$operation
=
new
DropCollection
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[
'session'
=>
$this
->
createSession
()]
);
$operation
->
execute
(
$this
->
getPrimaryServer
());
},
function
(
stdClass
$command
)
{
$this
->
assertObjectHasAttribute
(
'lsid'
,
$command
);
}
);
}
/**
* Asserts that a collection with the given name does not exist on the
* server.
...
...
tests/Operation/DropCollectionTest.php
View file @
142d24ec
...
...
@@ -19,6 +19,10 @@ class DropCollectionTest extends TestCase
{
$options
=
[];
foreach
(
$this
->
getInvalidSessionValues
()
as
$value
)
{
$options
[][]
=
[
'session'
=>
$value
];
}
foreach
(
$this
->
getInvalidArrayValues
()
as
$value
)
{
$options
[][]
=
[
'typeMap'
=>
$value
];
}
...
...
tests/Operation/DropDatabaseFunctionalTest.php
View file @
142d24ec
...
...
@@ -58,6 +58,27 @@ class DropDatabaseFunctionalTest extends FunctionalTestCase
$operation
->
execute
(
$server
);
}
public
function
testSessionOption
()
{
if
(
version_compare
(
$this
->
getServerVersion
(),
'3.6.0'
,
'<'
))
{
$this
->
markTestSkipped
(
'Sessions are not supported'
);
}
(
new
CommandObserver
)
->
observe
(
function
()
{
$operation
=
new
DropDatabase
(
$this
->
getDatabaseName
(),
[
'session'
=>
$this
->
createSession
()]
);
$operation
->
execute
(
$this
->
getPrimaryServer
());
},
function
(
stdClass
$command
)
{
$this
->
assertObjectHasAttribute
(
'lsid'
,
$command
);
}
);
}
/**
* Asserts that a database with the given name does not exist on the server.
*
...
...
tests/Operation/DropDatabaseTest.php
View file @
142d24ec
...
...
@@ -19,6 +19,10 @@ class DropDatabaseTest extends TestCase
{
$options
=
[];
foreach
(
$this
->
getInvalidSessionValues
()
as
$value
)
{
$options
[][]
=
[
'session'
=>
$value
];
}
foreach
(
$this
->
getInvalidArrayValues
()
as
$value
)
{
$options
[][]
=
[
'typeMap'
=>
$value
];
}
...
...
tests/Operation/DropIndexesFunctionalTest.php
View file @
142d24ec
...
...
@@ -88,6 +88,32 @@ class DropIndexesFunctionalTest extends FunctionalTestCase
}
}
public
function
testSessionOption
()
{
if
(
version_compare
(
$this
->
getServerVersion
(),
'3.6.0'
,
'<'
))
{
$this
->
markTestSkipped
(
'Sessions are not supported'
);
}
$operation
=
new
CreateIndexes
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[[
'key'
=>
[
'x'
=>
1
]]]);
$operation
->
execute
(
$this
->
getPrimaryServer
());
(
new
CommandObserver
)
->
observe
(
function
()
{
$operation
=
new
DropIndexes
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
'*'
,
[
'session'
=>
$this
->
createSession
()]
);
$operation
->
execute
(
$this
->
getPrimaryServer
());
},
function
(
stdClass
$command
)
{
$this
->
assertObjectHasAttribute
(
'lsid'
,
$command
);
}
);
}
/**
* Asserts that an index with the given name exists for the collection.
*
...
...
tests/Operation/DropIndexesTest.php
View file @
142d24ec
...
...
@@ -31,6 +31,10 @@ class DropIndexesTest extends TestCase
$options
[][]
=
[
'maxTimeMS'
=>
$value
];
}
foreach
(
$this
->
getInvalidSessionValues
()
as
$value
)
{
$options
[][]
=
[
'session'
=>
$value
];
}
foreach
(
$this
->
getInvalidArrayValues
()
as
$value
)
{
$options
[][]
=
[
'typeMap'
=>
$value
];
}
...
...
tests/Operation/FindAndModifyFunctionalTest.php
View file @
142d24ec
...
...
@@ -28,6 +28,28 @@ class FindAndModifyFunctionalTest extends FunctionalTestCase
);
}
public
function
testSessionOption
()
{
if
(
version_compare
(
$this
->
getServerVersion
(),
'3.6.0'
,
'<'
))
{
$this
->
markTestSkipped
(
'Sessions are not supported'
);
}
(
new
CommandObserver
)
->
observe
(
function
()
{
$operation
=
new
FindAndModify
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[
'remove'
=>
true
,
'session'
=>
$this
->
createSession
()]
);
$operation
->
execute
(
$this
->
getPrimaryServer
());
},
function
(
stdClass
$command
)
{
$this
->
assertObjectHasAttribute
(
'lsid'
,
$command
);
}
);
}
/**
* @dataProvider provideTypeMapOptionsAndExpectedDocument
*/
...
...
tests/Operation/FindAndModifyTest.php
View file @
142d24ec
...
...
@@ -51,6 +51,10 @@ class FindAndModifyTest extends TestCase
$options
[][]
=
[
'remove'
=>
$value
];
}
foreach
(
$this
->
getInvalidSessionValues
()
as
$value
)
{
$options
[][]
=
[
'session'
=>
$value
];
}
foreach
(
$this
->
getInvalidDocumentValues
()
as
$value
)
{
$options
[][]
=
[
'sort'
=>
$value
];
}
...
...
tests/Operation/FindFunctionalTest.php
View file @
142d24ec
...
...
@@ -82,6 +82,29 @@ class FindFunctionalTest extends FunctionalTestCase
}
}
public
function
testSessionOption
()
{
if
(
version_compare
(
$this
->
getServerVersion
(),
'3.6.0'
,
'<'
))
{
$this
->
markTestSkipped
(
'Sessions are not supported'
);
}
(
new
CommandObserver
)
->
observe
(
function
()
{
$operation
=
new
Find
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[],
[
'session'
=>
$this
->
createSession
()]
);
$operation
->
execute
(
$this
->
getPrimaryServer
());
},
function
(
stdClass
$command
)
{
$this
->
assertObjectHasAttribute
(
'lsid'
,
$command
);
}
);
}
/**
* @dataProvider provideTypeMapOptionsAndExpectedDocuments
*/
...
...
tests/Operation/FindTest.php
View file @
142d24ec
...
...
@@ -100,6 +100,10 @@ class FindTest extends TestCase
$options
[][]
=
[
'returnKey'
=>
$value
];
}
foreach
(
$this
->
getInvalidSessionValues
()
as
$value
)
{
$options
[][]
=
[
'session'
=>
$value
];
}
foreach
(
$this
->
getInvalidBooleanValues
()
as
$value
)
{
$options
[][]
=
[
'showRecordId'
=>
$value
];
}
...
...
tests/Operation/FunctionalTestCase.php
View file @
142d24ec
...
...
@@ -41,4 +41,9 @@ abstract class FunctionalTestCase extends BaseFunctionalTestCase
{
return
new
WriteConcern
(
-
2
);
}
protected
function
createSession
()
{
return
$this
->
manager
->
startSession
();
}
}
tests/Operation/InsertManyFunctionalTest.php
View file @
142d24ec
...
...
@@ -7,6 +7,8 @@ use MongoDB\InsertManyResult;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Model\BSONDocument
;
use
MongoDB\Operation\InsertMany
;
use
MongoDB\Tests\CommandObserver
;
use
stdClass
;
class
InsertManyFunctionalTest
extends
FunctionalTestCase
{
...
...
@@ -50,6 +52,29 @@ class InsertManyFunctionalTest extends FunctionalTestCase
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
public
function
testSessionOption
()
{
if
(
version_compare
(
$this
->
getServerVersion
(),
'3.6.0'
,
'<'
))
{
$this
->
markTestSkipped
(
'Sessions are not supported'
);
}
(
new
CommandObserver
)
->
observe
(
function
()
{
$operation
=
new
InsertMany
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[[
'_id'
=>
1
],
[
'_id'
=>
2
]],
[
'session'
=>
$this
->
createSession
()]
);
$operation
->
execute
(
$this
->
getPrimaryServer
());
},
function
(
stdClass
$command
)
{
$this
->
assertObjectHasAttribute
(
'lsid'
,
$command
);
}
);
}
public
function
testUnacknowledgedWriteConcern
()
{
$documents
=
[[
'x'
=>
11
]];
...
...
tests/Operation/InsertManyTest.php
View file @
142d24ec
...
...
@@ -55,6 +55,10 @@ class InsertManyTest extends TestCase
$options
[][]
=
[
'ordered'
=>
$value
];
}
foreach
(
$this
->
getInvalidSessionValues
()
as
$value
)
{
$options
[][]
=
[
'session'
=>
$value
];
}
foreach
(
$this
->
getInvalidWriteConcernValues
()
as
$value
)
{
$options
[][]
=
[
'writeConcern'
=>
$value
];
}
...
...
tests/Operation/InsertOneFunctionalTest.php
View file @
142d24ec
...
...
@@ -7,6 +7,8 @@ use MongoDB\InsertOneResult;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Model\BSONDocument
;
use
MongoDB\Operation\InsertOne
;
use
MongoDB\Tests\CommandObserver
;
use
stdClass
;
class
InsertOneFunctionalTest
extends
FunctionalTestCase
{
...
...
@@ -65,6 +67,29 @@ class InsertOneFunctionalTest extends FunctionalTestCase
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
public
function
testSessionOption
()
{
if
(
version_compare
(
$this
->
getServerVersion
(),
'3.6.0'
,
'<'
))
{
$this
->
markTestSkipped
(
'Sessions are not supported'
);
}
(
new
CommandObserver
)
->
observe
(
function
()
{
$operation
=
new
InsertOne
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[
'_id'
=>
1
],
[
'session'
=>
$this
->
createSession
()]
);
$operation
->
execute
(
$this
->
getPrimaryServer
());
},
function
(
stdClass
$command
)
{
$this
->
assertObjectHasAttribute
(
'lsid'
,
$command
);
}
);
}
public
function
testUnacknowledgedWriteConcern
()
{
$document
=
[
'x'
=>
11
];
...
...
tests/Operation/InsertOneTest.php
View file @
142d24ec
...
...
@@ -32,6 +32,10 @@ class InsertOneTest extends TestCase
$options
[][]
=
[
'bypassDocumentValidation'
=>
$value
];
}
foreach
(
$this
->
getInvalidSessionValues
()
as
$value
)
{
$options
[][]
=
[
'session'
=>
$value
];
}
foreach
(
$this
->
getInvalidWriteConcernValues
()
as
$value
)
{
$options
[][]
=
[
'writeConcern'
=>
$value
];
}
...
...
tests/Operation/ListCollectionsFunctionalTest.php
View file @
142d24ec
...
...
@@ -5,6 +5,8 @@ namespace MongoDB\Tests\Operation;
use
MongoDB\Operation\DropDatabase
;
use
MongoDB\Operation\InsertOne
;
use
MongoDB\Operation\ListCollections
;
use
MongoDB\Tests\CommandObserver
;
use
stdClass
;
class
ListCollectionsFunctionalTest
extends
FunctionalTestCase
{
...
...
@@ -44,4 +46,25 @@ class ListCollectionsFunctionalTest extends FunctionalTestCase
$this
->
assertCount
(
0
,
$collections
);
}
public
function
testSessionOption
()
{
if
(
version_compare
(
$this
->
getServerVersion
(),
'3.6.0'
,
'<'
))
{
$this
->
markTestSkipped
(
'Sessions are not supported'
);
}
(
new
CommandObserver
)
->
observe
(
function
()
{
$operation
=
new
ListCollections
(
$this
->
getDatabaseName
(),
[
'session'
=>
$this
->
createSession
()]
);
$operation
->
execute
(
$this
->
getPrimaryServer
());
},
function
(
stdClass
$command
)
{
$this
->
assertObjectHasAttribute
(
'lsid'
,
$command
);
}
);
}
}
tests/Operation/ListCollectionsTest.php
View file @
142d24ec
...
...
@@ -27,6 +27,10 @@ class ListCollectionsTest extends TestCase
$options
[][]
=
[
'maxTimeMS'
=>
$value
];
}
foreach
(
$this
->
getInvalidSessionValues
()
as
$value
)
{
$options
[][]
=
[
'session'
=>
$value
];
}
return
$options
;
}
}
tests/Operation/ListDatabasesFunctionalTest.php
0 → 100644
View file @
142d24ec
<?php
namespace
MongoDB\Tests\Operation
;
use
MongoDB\Operation\ListDatabases
;
use
MongoDB\Tests\CommandObserver
;
use
stdClass
;
class
ListDatabasesFunctionalTest
extends
FunctionalTestCase
{
public
function
testSessionOption
()
{
if
(
version_compare
(
$this
->
getServerVersion
(),
'3.6.0'
,
'<'
))
{
$this
->
markTestSkipped
(
'Sessions are not supported'
);
}
(
new
CommandObserver
)
->
observe
(
function
()
{
$operation
=
new
ListDatabases
(
[
'session'
=>
$this
->
createSession
()]
);
$operation
->
execute
(
$this
->
getPrimaryServer
());
},
function
(
stdClass
$command
)
{
$this
->
assertObjectHasAttribute
(
'lsid'
,
$command
);
}
);
}
}
tests/Operation/ListDatabasesTest.php
View file @
142d24ec
...
...
@@ -23,6 +23,10 @@ class ListDatabasesTest extends TestCase
$options
[][]
=
[
'maxTimeMS'
=>
$value
];
}
foreach
(
$this
->
getInvalidSessionValues
()
as
$value
)
{
$options
[][]
=
[
'session'
=>
$value
];
}
return
$options
;
}
}
tests/Operation/ListIndexesFunctionalTest.php
View file @
142d24ec
...
...
@@ -5,6 +5,8 @@ namespace MongoDB\Tests\Operation;
use
MongoDB\Operation\DropCollection
;
use
MongoDB\Operation\InsertOne
;
use
MongoDB\Operation\ListIndexes
;
use
MongoDB\Tests\CommandObserver
;
use
stdClass
;
class
ListIndexesFunctionalTest
extends
FunctionalTestCase
{
...
...
@@ -40,4 +42,26 @@ class ListIndexesFunctionalTest extends FunctionalTestCase
$this
->
assertCount
(
0
,
$indexes
);
}
public
function
testSessionOption
()
{
if
(
version_compare
(
$this
->
getServerVersion
(),
'3.6.0'
,
'<'
))
{
$this
->
markTestSkipped
(
'Sessions are not supported'
);
}
(
new
CommandObserver
)
->
observe
(
function
()
{
$operation
=
new
ListIndexes
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[
'session'
=>
$this
->
createSession
()]
);
$operation
->
execute
(
$this
->
getPrimaryServer
());
},
function
(
stdClass
$command
)
{
$this
->
assertObjectHasAttribute
(
'lsid'
,
$command
);
}
);
}
}
tests/Operation/ListIndexesTest.php
View file @
142d24ec
...
...
@@ -23,6 +23,10 @@ class ListIndexesTest extends TestCase
$options
[][]
=
[
'maxTimeMS'
=>
$value
];
}
foreach
(
$this
->
getInvalidSessionValues
()
as
$value
)
{
$options
[][]
=
[
'session'
=>
$value
];
}
return
$options
;
}
}
tests/Operation/MapReduceFunctionalTest.php
View file @
142d24ec
...
...
@@ -129,6 +129,33 @@ class MapReduceFunctionalTest extends FunctionalTestCase
$this
->
assertEmpty
(
$result
->
getTiming
());
}
public
function
testSessionOption
()
{
if
(
version_compare
(
$this
->
getServerVersion
(),
'3.6.0'
,
'<'
))
{
$this
->
markTestSkipped
(
'Sessions are not supported'
);
}
$this
->
createFixtures
(
3
);
(
new
CommandObserver
)
->
observe
(
function
()
{
$operation
=
new
MapReduce
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
new
Javascript
(
'function() { emit(this.x, this.y); }'
),
new
Javascript
(
'function(key, values) { return Array.sum(values); }'
),
[
'inline'
=>
1
],
[
'session'
=>
$this
->
createSession
()]
);
$operation
->
execute
(
$this
->
getPrimaryServer
());
},
function
(
stdClass
$command
)
{
$this
->
assertObjectHasAttribute
(
'lsid'
,
$command
);
}
);
}
/**
* @dataProvider provideTypeMapOptionsAndExpectedDocuments
*/
...
...
tests/Operation/MapReduceTest.php
View file @
142d24ec
...
...
@@ -83,6 +83,10 @@ class MapReduceTest extends TestCase
$options
[][]
=
[
'scope'
=>
$value
];
}
foreach
(
$this
->
getInvalidSessionValues
()
as
$value
)
{
$options
[][]
=
[
'session'
=>
$value
];
}
foreach
(
$this
->
getInvalidDocumentValues
()
as
$value
)
{
$options
[][]
=
[
'sort'
=>
$value
];
}
...
...
tests/Operation/UpdateFunctionalTest.php
View file @
142d24ec
This diff is collapsed.
Click to expand it.
tests/Operation/UpdateTest.php
View file @
142d24ec
This diff is collapsed.
Click to expand it.
tests/TestCase.php
View file @
142d24ec
This diff is collapsed.
Click to expand it.
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