vert-x3 / vertx-mongo-client

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

Mongo Client should not require Jackson Databind #293

Closed DemonicTutor closed 10 months ago

DemonicTutor commented 1 year ago

Version

since this commit: https://github.com/eclipse-vertx/vert.x/commit/c59300aa8aebb0ac66bbfae3244616869c930d7a jackson-databind is optional

Context

First time we want to use aggregate in one of our services.

Do you have a reproducer?

verts-mongo-client calls JsonObject's public static JsonObject mapFrom(Object obj) in some paths and in test scope the dependency is present.

  JsonObject.mapFrom(new JsonObject());
  JsonObject.mapFrom(new LinkedHashMap<>());
  JsonObject.mapFrom(Map.of("a", "b"));

throws io.vertx.core.json.DecodeException: Mapping java.util.Map is not available without Jackson Databind on the classpath

Steps to reproduce

mongo.aggregate("collection", new JsonArray("""
        [
           { "$group": { "_id": null, "myCount": { "$sum": 1 } } },
           { "$project": { "_id": 0 } }
        ]
        """))

or

mongo.aggregate("collection", JsonArray.of(
        new JsonObject("""
          { "$group": { "_id": null, "myCount": { "$sum": 1 } } }
          """),
        new JsonObject("""
          { "$project": { "_id": 0 } }
          """)
      ))

or

mongo.aggregate("collection", JsonArray.of(
      JsonObject.of("$group", JsonObject.of("_id", null, "myCount", JsonObject.of("$sum", 1))),
      JsonObject.of("$project", JsonObject.of("_id",  0))
      ))

Extra

tsegismont commented 10 months ago

Fixed by 1546a0f