From 126c9f850370914842a7609276de2364e62259f5 Mon Sep 17 00:00:00 2001 From: Ivan Samsonov Date: Mon, 15 Jun 2015 02:45:11 +0300 Subject: [PATCH] Connect via uri in core/connect if it is passed core/connect ignores :uri key and tries to connect 127.0.0.1:27017 instead. Patch fix this behaviour by checking uri key existance and trying to connect by uri if it's provided. --- src/clojure/monger/core.clj | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/clojure/monger/core.clj b/src/clojure/monger/core.clj index d3e3041..be6db26 100644 --- a/src/clojure/monger/core.clj +++ b/src/clojure/monger/core.clj @@ -90,12 +90,14 @@ (MongoClient. server-list creds options)) (MongoClient. ^ServerAddress server-address options)))) ([{ :keys [host port uri] :or { host *mongodb-host* port *mongodb-port* }}] - (MongoClient. ^String host ^Long port))) + (if uri + (MongoClient. (MongoClientURI. uri)) + (MongoClient. ^String host ^Long port)))) (defn ^MongoClient connect-with-credentials "Connect with provided credentials and default options" ([credentials] - (connect-with-credentials *mongodb-host* *mongodb-port* credentials)) + (connect-with-credentials *mongodb-host* *mongodb-port* credentials)) ([^String hostname credentials] (connect-with-credentials hostname *mongodb-port* credentials)) ([^String hostname port credentials]