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
ac5c1a72
Unverified
Commit
ac5c1a72
authored
Jul 23, 2019
by
Andreas Braun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PHPLIB-413: Add support for read concerns in aggregations with an $out stage
parent
aca250a2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
13 deletions
+16
-13
Collection.php
src/Collection.php
+6
-4
Database.php
src/Database.php
+6
-4
Context.php
tests/SpecTests/Context.php
+4
-0
CrudSpecTest.php
tests/SpecTests/CrudSpecTest.php
+0
-5
No files found.
src/Collection.php
View file @
ac5c1a72
...
...
@@ -69,6 +69,7 @@ class Collection
private
static
$wireVersionForFindAndModifyWriteConcern
=
4
;
private
static
$wireVersionForReadConcern
=
4
;
private
static
$wireVersionForWritableCommandWriteConcern
=
5
;
private
static
$wireVersionForReadConcernWithOutStage
=
8
;
private
$collectionName
;
private
$databaseName
;
...
...
@@ -201,15 +202,16 @@ class Collection
$server
=
$this
->
manager
->
selectServer
(
$options
[
'readPreference'
]);
/*
A "majority" read concern is not compatible with the $out stage, so
*
avoid providing the Collection's read concern if it would conflic
t.
/*
MongoDB 4.2 and later supports a read concern when an $out stage is
*
being used, but earlier versions do no
t.
*
* A read concern is also not compatible with transactions.
*/
if
(
!
isset
(
$options
[
'readConcern'
])
&&
!
(
$hasOutStage
&&
$this
->
readConcern
->
getLevel
()
===
ReadConcern
::
MAJORITY
)
&&
\MongoDB\server_supports_feature
(
$server
,
self
::
$wireVersionForReadConcern
)
&&
!
\MongoDB\is_in_transaction
(
$options
))
{
!
\MongoDB\is_in_transaction
(
$options
)
&&
(
!
$hasOutStage
||
\MongoDB\server_supports_feature
(
$server
,
self
::
$wireVersionForReadConcernWithOutStage
))
)
{
$options
[
'readConcern'
]
=
$this
->
readConcern
;
}
...
...
src/Database.php
View file @
ac5c1a72
...
...
@@ -48,6 +48,7 @@ class Database
];
private
static
$wireVersionForReadConcern
=
4
;
private
static
$wireVersionForWritableCommandWriteConcern
=
5
;
private
static
$wireVersionForReadConcernWithOutStage
=
8
;
private
$databaseName
;
private
$manager
;
...
...
@@ -186,15 +187,16 @@ class Database
$server
=
$this
->
manager
->
selectServer
(
$options
[
'readPreference'
]);
/*
A "majority" read concern is not compatible with the $out stage, so
*
avoid providing the Collection's read concern if it would conflic
t.
/*
MongoDB 4.2 and later supports a read concern when an $out stage is
*
being used, but earlier versions do no
t.
*
* A read concern is also not compatible with transactions.
*/
if
(
!
isset
(
$options
[
'readConcern'
])
&&
!
(
$hasOutStage
&&
$this
->
readConcern
->
getLevel
()
===
ReadConcern
::
MAJORITY
)
&&
\MongoDB\server_supports_feature
(
$server
,
self
::
$wireVersionForReadConcern
)
&&
!
\MongoDB\is_in_transaction
(
$options
))
{
!
\MongoDB\is_in_transaction
(
$options
)
&&
(
!
$hasOutStage
||
\MongoDB\server_supports_feature
(
$server
,
self
::
$wireVersionForReadConcernWithOutStage
))
)
{
$options
[
'readConcern'
]
=
$this
->
readConcern
;
}
...
...
tests/SpecTests/Context.php
View file @
ac5c1a72
...
...
@@ -59,6 +59,10 @@ final class Context
$clientOptions
=
isset
(
$test
->
clientOptions
)
?
(
array
)
$test
->
clientOptions
:
[];
if
(
isset
(
$test
->
outcome
->
collection
->
name
))
{
$o
->
outcomeCollectionName
=
$test
->
outcome
->
collection
->
name
;
}
$o
->
client
=
new
Client
(
FunctionalTestCase
::
getUri
(),
$clientOptions
);
return
$o
;
...
...
tests/SpecTests/CrudSpecTest.php
View file @
ac5c1a72
...
...
@@ -19,11 +19,6 @@ class CrudSpecTest extends FunctionalTestCase
'aggregate-merge: Aggregate with $merge and majority readConcern'
=>
'PHPLIB-438'
,
'aggregate-merge: Aggregate with $merge and local readConcern'
=>
'PHPLIB-438'
,
'aggregate-merge: Aggregate with $merge and available readConcern'
=>
'PHPLIB-438'
,
'aggregate-out-readConcern: readConcern majority with out stage'
=>
'PHPLIB-431'
,
'aggregate-out-readConcern: readConcern local with out stage'
=>
'PHPLIB-431'
,
'aggregate-out-readConcern: readConcern available with out stage'
=>
'PHPLIB-431'
,
'aggregate-out-readConcern: readConcern linearizable with out stage'
=>
'PHPLIB-431'
,
'aggregate-out-readConcern: invalid readConcern with out stage'
=>
'PHPLIB-431'
,
'bulkWrite-arrayFilters: BulkWrite with arrayFilters'
=>
'Fails due to command assertions'
,
'updateWithPipelines: UpdateOne using pipelines'
=>
'PHPLIB-418'
,
'updateWithPipelines: UpdateMany using pipelines'
=>
'PHPLIB-418'
,
...
...
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