michaelklishin / monger

Monger is an idiomatic Clojure MongoDB driver with sane defaults, batteries included, well documented, low overhead
http://clojuremongodb.info
484 stars 104 forks source link

mongo-options-builder does not support uuidRepresentation option #212

Closed okorz001 closed 2 years ago

okorz001 commented 2 years ago

uuidRepresentation option was added in 3.12.0. This allows changing the UUID codec implementation -- particularly it allows a client to use a standard UUID codec instead of the legacy Java codec which may be incompatible with other drivers.

https://github.com/mongodb/mongo-java-driver/blob/r3.12.0/driver-legacy/src/main/com/mongodb/MongoClientOptions.java#L1457-L1470

The uuidRepresentation option takes a UuidRepresentation enum, which is annoying (but trivial) to deal with. It would be nice if we could pass a string or preferably a keyword instead.

As a workaround, I am using the following wrapper. I was too lazy to support a keyword.

(defn- mongo-options
  [opts]
  (let [mob (monger/mongo-options-builder opts)
        {:keys [uuid-representation]} opts]
    (when uuid-representation
      (.uuidRepresentation mob (UuidRepresentation/valueOf uuid-representation)))
    (.build mob)))
okorz001 commented 2 years ago

I see master actually uses 3.12 already so I could submit a patch for this. Are there any plans to do a 3.6.0 release?

michaelklishin commented 2 years ago

@okorz001 a new release should not take long.

okorz001 commented 2 years ago

Thanks for the quick response!