-
Type: Bug
-
Resolution: Duplicate
-
Priority: Minor - P4
-
None
-
Affects Version/s: 1.0.0
-
Component/s: None
-
None
The count() method (implementing the Countable interface) was originally documented as returning "the number of operations that have been added to the bulk". At some point, this was changed to report the number of expected round-trips to the server (via bulk->commands.len). I propose restoring the original behavior, and moving the round-trip estimation to a new method.
On a separate, but related, note: count() currently returns 4 irrespective of the ordered option in:
$bulk = new MongoDB\Driver\BulkWrite(['ordered' => false]); $bulk->insert(['_id' => 1, 'x' => 1]); $bulk->insert(['_id' => 2, 'x' => 2]); $bulk->update( ['x' => 2], ['$set' => ['x' => 1]], ['limit' => 1, 'upsert' => false] ); $bulk->delete(['x' => 1], ['limit' => 1]); $bulk->update( ['_id' => 3], ['$set' => ['x' => 3]], ['limit' => 1, 'upsert' => true] );
I would expect an unordered bulk to only require three round-trips.
- is duplicated by
-
PHPC-680 BulkWrite::count() should return number of operations instead of estimated round-trips
- Closed
- is related to
-
CDRIVER-653 Rearrange unordered bulk ops
- Closed