Skip to content

Support for updates with aggregation pipeline #994

@timwhitlock

Description

@timwhitlock

Description

I'm unable to execute an update with a pipeline such as using the new (upcoming) aggregate $set operator. This fails before the command is executed as shown below.

I presume that support simply hasn't been added yet, but can you say if/when it will be supported, or if there's a workaround I can use to execute this?

Thank you.

Environment

PHP 7.2.16 on Mac OS X

Tried with latest stable driver 1.5.5 and also 1.6.0alpha2.

Test Script

<?php
$batch = new MongoDB\Driver\BulkWrite(['ordered'=>true]);
$batch->update(
    [ ],
    [ [ '$set' => ['foo'=>'bar'] ] ], // <- aggregate pipeline
    [ 'limit' => 0 ]
);

Expected and Actual Behavior

Fails with MongoDB\Driver\Exception\InvalidArgumentException:

invalid argument for replace: keys cannot begin with "$": "$set"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions