Skip to content

Commit f3e9e1e

Browse files
derickrjmikola
authored andcommitted
PHPLIB-118: Specify "root" option in typemap, as it's separate from "document"
1 parent ab3f051 commit f3e9e1e

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

src/Operation/Count.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function __construct($databaseName, $collectionName, array $filter = arra
8585
public function execute(Server $server)
8686
{
8787
$cursor = $server->executeCommand($this->databaseName, $this->createCommand());
88-
$cursor->setTypeMap(array('document' => 'array'));
88+
$cursor->setTypeMap(array('root' => 'array', 'document' => 'array'));
8989
$result = current($cursor->toArray());
9090

9191
if (empty($result['ok'])) {

src/Operation/CreateIndexes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ private function executeCommand(Server $server)
9191
));
9292

9393
$cursor = $server->executeCommand($this->databaseName, $command);
94-
$cursor->setTypeMap(array('document' => 'array'));
94+
$cursor->setTypeMap(array('root' => 'array', 'document' => 'array'));
9595
$result = current($cursor->toArray());
9696

9797
if (empty($result['ok'])) {

src/Operation/ListCollections.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ private function executeCommand(Server $server)
8585
}
8686

8787
$cursor = $server->executeCommand($this->databaseName, new Command($cmd));
88-
$cursor->setTypeMap(array('document' => 'array'));
88+
$cursor->setTypeMap(array('root' => 'array', 'document' => 'array'));
8989

9090
return new CollectionInfoCommandIterator($cursor);
9191
}
@@ -115,7 +115,7 @@ private function executeLegacy(Server $server)
115115
: array();
116116

117117
$cursor = $server->executeQuery($this->databaseName . '.system.namespaces', new Query($filter, $options));
118-
$cursor->setTypeMap(array('document' => 'array'));
118+
$cursor->setTypeMap(array('root' => 'array', 'document' => 'array'));
119119

120120
return new CollectionInfoLegacyIterator($cursor);
121121
}

src/Operation/ListDatabases.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function execute(Server $server)
5555
}
5656

5757
$cursor = $server->executeCommand('admin', new Command($cmd));
58-
$cursor->setTypeMap(array('document' => 'array'));
58+
$cursor->setTypeMap(array('root' => 'array', 'document' => 'array'));
5959
$result = current($cursor->toArray());
6060

6161
if (empty($result['ok'])) {

src/Operation/ListIndexes.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ private function executeCommand(Server $server)
7676
}
7777

7878
$cursor = $server->executeCommand($this->databaseName, new Command($cmd));
79-
$cursor->setTypeMap(array('document' => 'array'));
79+
$cursor->setTypeMap(array('root' => 'array', 'document' => 'array'));
8080

8181
return new IndexInfoIteratorIterator($cursor);
8282
}
@@ -97,7 +97,7 @@ private function executeLegacy(Server $server)
9797
: array();
9898

9999
$cursor = $server->executeQuery($this->databaseName . '.system.indexes', new Query($filter, $options));
100-
$cursor->setTypeMap(array('document' => 'array'));
100+
$cursor->setTypeMap(array('root' => 'array', 'document' => 'array'));
101101

102102
return new IndexInfoIteratorIterator($cursor);
103103
}

tests/FunctionalTestCase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ protected function assertCollectionCount($namespace, $count)
2323
list($databaseName, $collectionName) = explode('.', $namespace, 2);
2424

2525
$cursor = $this->manager->executeCommand($databaseName, new Command(array('count' => $collectionName)));
26-
$cursor->setTypeMap(array('document' => 'array'));
26+
$cursor->setTypeMap(array('root' => 'array', 'document' => 'array'));
2727
$document = current($cursor->toArray());
2828

2929
$this->assertArrayHasKey('n', $document);
@@ -76,7 +76,7 @@ protected function getServerVersion(ReadPreference $readPreference = null)
7676
$readPreference ?: new ReadPreference(ReadPreference::RP_PRIMARY)
7777
);
7878

79-
$cursor->setTypeMap(array('document' => 'array'));
79+
$cursor->setTypeMap(array('root' => 'array', 'document' => 'array'));
8080
$document = current($cursor->toArray());
8181

8282
return $document['version'];

0 commit comments

Comments
 (0)