Open DieterDePaepe opened 7 years ago
@johnoliver This works as intended?
Hello,I also encountered this problem。Any idea on how to resolve this problem?
I have submitted a fix for this, although to be honest I actually view this as a bug in mongos driver. It seems inconsistent on their part that inserts call JsonObjectCodec#generateIdIfAbsentFromDocument
if needed, however an upsert does not.
This fix causes ans exception if upsert results in insert and _id from query is a JsonObject
java.lang.ClassCastException: io.vertx.core.json.JsonObject cannot be cast to java.lang.CharSequence at io.vertx.core.json.JsonObject.getString(JsonObject.java:111) ~[vertx-core-3.5.3.jar:3.5.3] at io.vertx.ext.mongo.impl.MongoClientImpl.generateIdIfNeeded(MongoClientImpl.java:224) ~[vertx-mongo-client-3.5.3.jar:3.5.3] at io.vertx.ext.mongo.impl.MongoClientImpl.updateCollectionWithOptions(MongoClientImpl.java:202) ~[vertx-mongo-client-3.5.3.jar:3.5.3]
The following code still generates an ObjectId for newly added elements, rather than the expected string id. I tried tracing the problem, but lost my way in the callback structures in the libraries.
Using version 3.3.3.