Skip to content

Commit ba9f715

Browse files
committed
Revert BC break on Collection::aggregate and watch
1 parent acc21d4 commit ba9f715

File tree

3 files changed

+4
-36
lines changed

3 files changed

+4
-36
lines changed

psalm-baseline.xml

-5
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,6 @@
223223
<MixedPropertyTypeCoercion>
224224
<code><![CDATA[$options['builderEncoder'] ?? new BuilderEncoder()]]></code>
225225
</MixedPropertyTypeCoercion>
226-
<PossiblyInvalidArgument>
227-
<code><![CDATA[$pipeline]]></code>
228-
<code><![CDATA[$pipeline]]></code>
229-
<code><![CDATA[$pipeline]]></code>
230-
</PossiblyInvalidArgument>
231226
</file>
232227
<file src="src/Command/ListCollections.php">
233228
<MixedAssignment>

src/Collection.php

+2-5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
use MongoDB\BSON\JavascriptInterface;
2424
use MongoDB\BSON\PackedArray;
2525
use MongoDB\Builder\BuilderEncoder;
26-
use MongoDB\Builder\Pipeline;
2726
use MongoDB\Codec\DocumentCodec;
2827
use MongoDB\Codec\Encoder;
2928
use MongoDB\Driver\CursorInterface;
@@ -222,9 +221,8 @@ public function __toString()
222221
* @throws InvalidArgumentException for parameter/option parsing errors
223222
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
224223
*/
225-
public function aggregate(array|Pipeline $pipeline, array $options = [])
224+
public function aggregate(array $pipeline, array $options = [])
226225
{
227-
$pipeline = $this->builderEncoder->encodeIfSupported($pipeline);
228226
$hasWriteStage = is_last_pipeline_operator_write($pipeline);
229227

230228
$options = $this->inheritReadPreference($options);
@@ -1098,9 +1096,8 @@ public function updateSearchIndex(string $name, array|object $definition, array
10981096
* @return ChangeStream
10991097
* @throws InvalidArgumentException for parameter/option parsing errors
11001098
*/
1101-
public function watch(array|Pipeline $pipeline = [], array $options = [])
1099+
public function watch(array $pipeline = [], array $options = [])
11021100
{
1103-
$pipeline = $this->builderEncoder->encodeIfSupported($pipeline);
11041101
$options = $this->inheritReadOptions($options);
11051102
$options = $this->inheritCodecOrTypeMap($options);
11061103

tests/Collection/BuilderCollectionFunctionalTest.php

+2-26
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace MongoDB\Tests\Collection;
44

5-
use MongoDB\Builder\Expression;
65
use MongoDB\Builder\Pipeline;
76
use MongoDB\Builder\Query;
87
use MongoDB\Builder\Stage;
@@ -18,15 +17,7 @@ public function setUp(): void
1817

1918
public function testAggregate(): void
2019
{
21-
$this->collection->insertMany([['x' => 10], ['x' => 10], ['x' => 10]]);
22-
$pipeline = new Pipeline(
23-
Stage::bucketAuto(
24-
groupBy: Expression::intFieldPath('x'),
25-
buckets: 2,
26-
),
27-
);
28-
$results = $this->collection->aggregate($pipeline)->toArray();
29-
$this->assertCount(2, $results);
20+
$this->markTestSkipped('Not supported yet');
3021
}
3122

3223
public function testBulkWriteDeleteMany(): void
@@ -254,21 +245,6 @@ public function testUpdateManyWithPipeline(): void
254245

255246
public function testWatch(): void
256247
{
257-
$this->skipIfChangeStreamIsNotSupported();
258-
259-
if ($this->isShardedCluster()) {
260-
$this->markTestSkipped('Test does not apply on sharded clusters: need more than a single getMore call on the change stream.');
261-
}
262-
263-
$pipeline = new Pipeline(
264-
Stage::match(operationType: Query::eq('insert')),
265-
);
266-
$changeStream = $this->collection->watch($pipeline);
267-
$changeStream->rewind();
268-
$this->assertNull($changeStream->current());
269-
$this->collection->insertOne(['x' => 3]);
270-
$changeStream->next();
271-
$this->assertTrue($changeStream->valid());
272-
$this->assertEquals('insert', $changeStream->current()->operationType);
248+
$this->markTestSkipped('Not supported yet');
273249
}
274250
}

0 commit comments

Comments
 (0)