Commit a0047660 authored by Andreas Braun's avatar Andreas Braun Committed by Jeremy Mikola

PHPLIB-179: Don't apply typeMap if useCursor is false

parent ad6c56db
...@@ -179,7 +179,7 @@ class Collection ...@@ -179,7 +179,7 @@ class Collection
$options['readPreference'] = new ReadPreference(ReadPreference::RP_PRIMARY); $options['readPreference'] = new ReadPreference(ReadPreference::RP_PRIMARY);
} }
if ( ! isset($options['typeMap'])) { if ( ! isset($options['typeMap']) && ( ! isset($options['useCursor']) || $options['useCursor'])) {
$options['typeMap'] = $this->typeMap; $options['typeMap'] = $this->typeMap;
} }
......
...@@ -71,4 +71,25 @@ class AggregateFunctionalTest extends FunctionalTestCase ...@@ -71,4 +71,25 @@ class AggregateFunctionalTest extends FunctionalTestCase
$operation = new DropCollection($this->getDatabaseName(), $outputCollection->getCollectionName()); $operation = new DropCollection($this->getDatabaseName(), $outputCollection->getCollectionName());
$operation->execute($this->getPrimaryServer()); $operation->execute($this->getPrimaryServer());
} }
public function testAggregateWithoutCursorDoesNotApplyTypemap()
{
$pipeline = [
['$group' => [
'_id' => null,
'count' => ['$sum' => 1]
]]
];
$options = ['useCursor' => false];
$result = $this->collection->aggregate($pipeline, $options);
$expected = [
[
'_id' => null,
'count' => 3,
],
];
$this->assertSameDocuments($expected, $result);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment