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
a2f87dc6
Unverified
Commit
a2f87dc6
authored
Feb 04, 2020
by
Andreas Braun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PHPLIB-499: Fall back to provided namespace if index info doesn't contain it
parent
150177a5
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
2 deletions
+24
-2
IndexInfoIteratorIterator.php
src/Model/IndexInfoIteratorIterator.php
+22
-1
ListIndexes.php
src/Operation/ListIndexes.php
+1
-1
ListIndexesFunctionalTest.php
tests/Operation/ListIndexesFunctionalTest.php
+1
-0
No files found.
src/Model/IndexInfoIteratorIterator.php
View file @
a2f87dc6
...
...
@@ -18,6 +18,8 @@
namespace
MongoDB\Model
;
use
IteratorIterator
;
use
Traversable
;
use
function
array_key_exists
;
/**
* IndexInfoIterator for both listIndexes command and legacy query results.
...
...
@@ -34,6 +36,19 @@ use IteratorIterator;
*/
class
IndexInfoIteratorIterator
extends
IteratorIterator
implements
IndexInfoIterator
{
/** @var string|null $ns */
private
$ns
;
/**
* @param string|null $ns
*/
public
function
__construct
(
Traversable
$iterator
,
$ns
=
null
)
{
parent
::
__construct
(
$iterator
);
$this
->
ns
=
$ns
;
}
/**
* Return the current element as an IndexInfo instance.
*
...
...
@@ -43,6 +58,12 @@ class IndexInfoIteratorIterator extends IteratorIterator implements IndexInfoIte
*/
public
function
current
()
{
return
new
IndexInfo
(
parent
::
current
());
$info
=
parent
::
current
();
if
(
!
array_key_exists
(
'ns'
,
$info
)
&&
$this
->
ns
!==
null
)
{
$info
[
'ns'
]
=
$this
->
ns
;
}
return
new
IndexInfo
(
$info
);
}
}
src/Operation/ListIndexes.php
View file @
a2f87dc6
...
...
@@ -149,6 +149,6 @@ class ListIndexes implements Executable
$cursor
->
setTypeMap
([
'root'
=>
'array'
,
'document'
=>
'array'
]);
return
new
IndexInfoIteratorIterator
(
new
CachingIterator
(
$cursor
));
return
new
IndexInfoIteratorIterator
(
new
CachingIterator
(
$cursor
)
,
$this
->
databaseName
.
'.'
.
$this
->
collectionName
);
}
}
tests/Operation/ListIndexesFunctionalTest.php
View file @
a2f87dc6
...
...
@@ -31,6 +31,7 @@ class ListIndexesFunctionalTest extends FunctionalTestCase
foreach
(
$indexes
as
$index
)
{
$this
->
assertInstanceOf
(
IndexInfo
::
class
,
$index
);
$this
->
assertEquals
([
'_id'
=>
1
],
$index
->
getKey
());
$this
->
assertSame
(
$this
->
getNamespace
(),
$index
->
getNamespace
());
}
}
...
...
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