From 8127d26442faf9ed4f3ce436f73bd59c427bd19a Mon Sep 17 00:00:00 2001 From: "Michael S. Klishin" Date: Tue, 29 Nov 2011 15:44:55 +0400 Subject: [PATCH] Fix monger.util/get-id for persistent maps with string keys --- src/monger/util.clj | 2 +- test/monger/test/collection.clj | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/monger/util.clj b/src/monger/util.clj index 8651ab3..78707d7 100644 --- a/src/monger/util.clj +++ b/src/monger/util.clj @@ -41,4 +41,4 @@ IPersistentMap (get-id [^IPersistentMap object] - (or (:_id object) ("_id" object)))) + (or (:_id object) (object "_id")))) diff --git a/test/monger/test/collection.clj b/test/monger/test/collection.clj index c1b3a34..9e5012f 100644 --- a/test/monger/test/collection.clj +++ b/test/monger/test/collection.clj @@ -46,6 +46,13 @@ (mgcol/insert "people" doc) (is (not (nil? (monger.util/get-id doc)))))) +(deftest insert-a-map-with-id-and-with-default-write-concern + (let [collection "people" + id (ObjectId.) + doc { :name "Joe", :age 30 "_id" id } + result (mgcol/insert "people" doc)] + (is (= id (monger.util/get-id doc))))) + ;;