Revert BulkWrite::count() to counting total write ops and create new getNumRoundTrips() method

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Duplicate
    • Priority: Minor - P4
    • None
    • Affects Version/s: 1.0.0
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • 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.

              Assignee:
              Unassigned
              Reporter:
              Jeremy Mikola
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: