Skip to content

Commit 76344d1

Browse files
committed
Merge pull request #107
2 parents ad6c56d + a004766 commit 76344d1

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/Collection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public function aggregate(array $pipeline, array $options = [])
179179
$options['readPreference'] = new ReadPreference(ReadPreference::RP_PRIMARY);
180180
}
181181

182-
if ( ! isset($options['typeMap'])) {
182+
if ( ! isset($options['typeMap']) && ( ! isset($options['useCursor']) || $options['useCursor'])) {
183183
$options['typeMap'] = $this->typeMap;
184184
}
185185

tests/Collection/CrudSpec/AggregateFunctionalTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,25 @@ public function testAggregateWithOut()
7171
$operation = new DropCollection($this->getDatabaseName(), $outputCollection->getCollectionName());
7272
$operation->execute($this->getPrimaryServer());
7373
}
74+
75+
public function testAggregateWithoutCursorDoesNotApplyTypemap()
76+
{
77+
$pipeline = [
78+
['$group' => [
79+
'_id' => null,
80+
'count' => ['$sum' => 1]
81+
]]
82+
];
83+
$options = ['useCursor' => false];
84+
$result = $this->collection->aggregate($pipeline, $options);
85+
86+
$expected = [
87+
[
88+
'_id' => null,
89+
'count' => 3,
90+
],
91+
];
92+
93+
$this->assertSameDocuments($expected, $result);
94+
}
7495
}

0 commit comments

Comments
 (0)