vert-x3 / vertx-mongo-client

Mongo Client for Eclipse Vert.x
http://vertx.io
Apache License 2.0
58 stars 98 forks source link

Bulk write missing inserted ids in response #284

Closed kofiStariji closed 10 months ago

kofiStariji commented 2 years ago

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
    );
  }

...
tsegismont commented 2 years ago

Would you like to contribute?

kofiStariji commented 2 years ago

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

tsegismont commented 2 years ago
  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)
kofiStariji commented 2 years ago

@tsegismont hi, I created pull request and tried to drop email to vertx-dev@googlegroups.com, 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.

tsegismont commented 10 months ago

Closed by 056bff0