vertx-mongo-client icon indicating copy to clipboard operation
vertx-mongo-client copied to clipboard

Bulk write missing inserted ids in response

Open kofiStariji opened this issue 2 years ago • 4 comments

Using latest vertx mongo client when bulkWrite is called in response we are missing list of inserted item ids, this list is part of response inside mongodb driver:

package com.mongodb.bulk;

 public abstract class BulkWriteResult {

...
   
/**
     * Gets an unmodifiable list of inserted items, or the empty list if there were none.
     *
     * @return a list of inserted items, or the empty list if there were none.
     * @throws java.lang.UnsupportedOperationException if the write was unacknowledged.
     * @see com.mongodb.WriteConcern#UNACKNOWLEDGED
     * @since 4.0
     */
    public abstract List<BulkWriteInsert> getInserts();

...

but it is not mapped after successful operation (only list of upsert ids is mapped):

package io.vertx.ext.mongo.impl;

class Utils {
...

static MongoClientBulkWriteResult toMongoClientBulkWriteResult(BulkWriteResult bulkWriteResult) {
    if (!bulkWriteResult.wasAcknowledged()) {
      return null;
    }

    List<JsonObject> upsertResult = bulkWriteResult.getUpserts().stream().map(upsert -> {
      JsonObject upsertValue = convertUpsertId(upsert.getId());
      upsertValue.put(MongoClientBulkWriteResult.INDEX, upsert.getIndex());
      return upsertValue;
    }).collect(Collectors.toList());

    return new MongoClientBulkWriteResult(
      bulkWriteResult.getInsertedCount(),
      bulkWriteResult.getMatchedCount(),
      bulkWriteResult.getDeletedCount(),
      bulkWriteResult.getModifiedCount(),
      upsertResult
    );
  }

...

kofiStariji avatar Jul 04 '22 11:07 kofiStariji

Would you like to contribute?

tsegismont avatar Jul 04 '22 12:07 tsegismont

Yes, I would. I will probably need someone help with initial steps (Eclipse user id and ECA sign)...

kofiStariji avatar Jul 04 '22 12:07 kofiStariji

  1. Sign the ECA http://www.eclipse.org/contribute/cla
  2. Configure your fork so that the author email and user email are the same as the one of your Eclipse account
  3. Sign-off your commit before pushing (with -s)

tsegismont avatar Jul 04 '22 13:07 tsegismont

@tsegismont hi, I created pull request and tried to drop email to [email protected], as it is stated in guidelines... but I got error from mail server that I do not have permissions to post there, maybe I miss some of steps... Please review pull request when you have time.

kofiStariji avatar Jul 04 '22 20:07 kofiStariji

Closed by 056bff0

tsegismont avatar Nov 06 '23 10:11 tsegismont