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
f6727da7
Unverified
Commit
f6727da7
authored
Mar 30, 2020
by
Andreas Braun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PHPLIB-539: Allow hinting for delete
parent
99101b87
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
55 additions
and
0 deletions
+55
-0
apiargs-MongoDBCollection-method-deleteMany-option.yaml
...s/apiargs-MongoDBCollection-method-deleteMany-option.yaml
+9
-0
apiargs-MongoDBCollection-method-deleteOne-option.yaml
...es/apiargs-MongoDBCollection-method-deleteOne-option.yaml
+9
-0
Delete.php
src/Operation/Delete.php
+23
-0
DeleteMany.php
src/Operation/DeleteMany.php
+7
-0
DeleteOne.php
src/Operation/DeleteOne.php
+7
-0
No files found.
docs/includes/apiargs-MongoDBCollection-method-deleteMany-option.yaml
View file @
f6727da7
...
@@ -2,6 +2,15 @@ source:
...
@@ -2,6 +2,15 @@ source:
file
:
apiargs-MongoDBCollection-common-option.yaml
file
:
apiargs-MongoDBCollection-common-option.yaml
ref
:
collation
ref
:
collation
---
---
source
:
file
:
apiargs-common-option.yaml
ref
:
hint
post
:
|
This option is available in MongoDB 4.4+ and will result in an exception at
execution time if specified for an older server version.
.. versionadded:: 1.7
---
source
:
source
:
file
:
apiargs-common-option.yaml
file
:
apiargs-common-option.yaml
ref
:
session
ref
:
session
...
...
docs/includes/apiargs-MongoDBCollection-method-deleteOne-option.yaml
View file @
f6727da7
...
@@ -2,6 +2,15 @@ source:
...
@@ -2,6 +2,15 @@ source:
file
:
apiargs-MongoDBCollection-common-option.yaml
file
:
apiargs-MongoDBCollection-common-option.yaml
ref
:
collation
ref
:
collation
---
---
source
:
file
:
apiargs-common-option.yaml
ref
:
hint
post
:
|
This option is available in MongoDB 4.4+ and will result in an exception at
execution time if specified for an older server version.
.. versionadded:: 1.7
---
source
:
source
:
file
:
apiargs-common-option.yaml
file
:
apiargs-common-option.yaml
ref
:
session
ref
:
session
...
...
src/Operation/Delete.php
View file @
f6727da7
...
@@ -27,6 +27,7 @@ use MongoDB\Exception\InvalidArgumentException;
...
@@ -27,6 +27,7 @@ use MongoDB\Exception\InvalidArgumentException;
use
MongoDB\Exception\UnsupportedException
;
use
MongoDB\Exception\UnsupportedException
;
use
function
is_array
;
use
function
is_array
;
use
function
is_object
;
use
function
is_object
;
use
function
is_string
;
use
function
MongoDB
\server_supports_feature
;
use
function
MongoDB
\server_supports_feature
;
/**
/**
...
@@ -43,6 +44,9 @@ class Delete implements Executable, Explainable
...
@@ -43,6 +44,9 @@ class Delete implements Executable, Explainable
/** @var integer */
/** @var integer */
private
static
$wireVersionForCollation
=
5
;
private
static
$wireVersionForCollation
=
5
;
/** @var int */
private
static
$wireVersionForHint
=
9
;
/** @var string */
/** @var string */
private
$databaseName
;
private
$databaseName
;
...
@@ -68,6 +72,13 @@ class Delete implements Executable, Explainable
...
@@ -68,6 +72,13 @@ class Delete implements Executable, Explainable
* This is not supported for server versions < 3.4 and will result in an
* This is not supported for server versions < 3.4 and will result in an
* exception at execution time if used.
* exception at execution time if used.
*
*
* * hint (string|document): The index to use. Specify either the index
* name as a string or the index key pattern as a document. If specified,
* then the query system will only consider plans using the hinted index.
*
* This is not supported for server versions < 4.4 and will result in an
* exception at execution time if used.
*
* * session (MongoDB\Driver\Session): Client session.
* * session (MongoDB\Driver\Session): Client session.
*
*
* Sessions are not supported for server versions < 3.6.
* Sessions are not supported for server versions < 3.6.
...
@@ -97,6 +108,10 @@ class Delete implements Executable, Explainable
...
@@ -97,6 +108,10 @@ class Delete implements Executable, Explainable
throw
InvalidArgumentException
::
invalidType
(
'"collation" option'
,
$options
[
'collation'
],
'array or object'
);
throw
InvalidArgumentException
::
invalidType
(
'"collation" option'
,
$options
[
'collation'
],
'array or object'
);
}
}
if
(
isset
(
$options
[
'hint'
])
&&
!
is_string
(
$options
[
'hint'
])
&&
!
is_array
(
$options
[
'hint'
])
&&
!
is_object
(
$options
[
'hint'
]))
{
throw
InvalidArgumentException
::
invalidType
(
'"hint" option'
,
$options
[
'hint'
],
[
'string'
,
'array'
,
'object'
]);
}
if
(
isset
(
$options
[
'session'
])
&&
!
$options
[
'session'
]
instanceof
Session
)
{
if
(
isset
(
$options
[
'session'
])
&&
!
$options
[
'session'
]
instanceof
Session
)
{
throw
InvalidArgumentException
::
invalidType
(
'"session" option'
,
$options
[
'session'
],
Session
::
class
);
throw
InvalidArgumentException
::
invalidType
(
'"session" option'
,
$options
[
'session'
],
Session
::
class
);
}
}
...
@@ -130,6 +145,10 @@ class Delete implements Executable, Explainable
...
@@ -130,6 +145,10 @@ class Delete implements Executable, Explainable
throw
UnsupportedException
::
collationNotSupported
();
throw
UnsupportedException
::
collationNotSupported
();
}
}
if
(
isset
(
$this
->
options
[
'hint'
])
&&
!
server_supports_feature
(
$server
,
self
::
$wireVersionForHint
))
{
throw
UnsupportedException
::
hintNotSupported
();
}
$inTransaction
=
isset
(
$this
->
options
[
'session'
])
&&
$this
->
options
[
'session'
]
->
isInTransaction
();
$inTransaction
=
isset
(
$this
->
options
[
'session'
])
&&
$this
->
options
[
'session'
]
->
isInTransaction
();
if
(
$inTransaction
&&
isset
(
$this
->
options
[
'writeConcern'
]))
{
if
(
$inTransaction
&&
isset
(
$this
->
options
[
'writeConcern'
]))
{
throw
UnsupportedException
::
writeConcernNotSupportedInTransaction
();
throw
UnsupportedException
::
writeConcernNotSupportedInTransaction
();
...
@@ -170,6 +189,10 @@ class Delete implements Executable, Explainable
...
@@ -170,6 +189,10 @@ class Delete implements Executable, Explainable
$deleteOptions
[
'collation'
]
=
(
object
)
$this
->
options
[
'collation'
];
$deleteOptions
[
'collation'
]
=
(
object
)
$this
->
options
[
'collation'
];
}
}
if
(
isset
(
$this
->
options
[
'hint'
]))
{
$deleteOptions
[
'hint'
]
=
$this
->
options
[
'hint'
];
}
return
$deleteOptions
;
return
$deleteOptions
;
}
}
...
...
src/Operation/DeleteMany.php
View file @
f6727da7
...
@@ -45,6 +45,13 @@ class DeleteMany implements Executable, Explainable
...
@@ -45,6 +45,13 @@ class DeleteMany implements Executable, Explainable
* This is not supported for server versions < 3.4 and will result in an
* This is not supported for server versions < 3.4 and will result in an
* exception at execution time if used.
* exception at execution time if used.
*
*
* * hint (string|document): The index to use. Specify either the index
* name as a string or the index key pattern as a document. If specified,
* then the query system will only consider plans using the hinted index.
*
* This is not supported for server versions < 4.4 and will result in an
* exception at execution time if used.
*
* * session (MongoDB\Driver\Session): Client session.
* * session (MongoDB\Driver\Session): Client session.
*
*
* Sessions are not supported for server versions < 3.6.
* Sessions are not supported for server versions < 3.6.
...
...
src/Operation/DeleteOne.php
View file @
f6727da7
...
@@ -45,6 +45,13 @@ class DeleteOne implements Executable, Explainable
...
@@ -45,6 +45,13 @@ class DeleteOne implements Executable, Explainable
* This is not supported for server versions < 3.4 and will result in an
* This is not supported for server versions < 3.4 and will result in an
* exception at execution time if used.
* exception at execution time if used.
*
*
* * hint (string|document): The index to use. Specify either the index
* name as a string or the index key pattern as a document. If specified,
* then the query system will only consider plans using the hinted index.
*
* This is not supported for server versions < 4.4 and will result in an
* exception at execution time if used.
*
* * session (MongoDB\Driver\Session): Client session.
* * session (MongoDB\Driver\Session): Client session.
*
*
* Sessions are not supported for server versions < 3.6.
* Sessions are not supported for server versions < 3.6.
...
...
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