Browse files

Merge pull request #95 from bwo/master

enable adding sets of keywords
  • Loading branch information...
2 parents ad63607 + 8bd39c8 commit 6abfee34a82f7544827930f1928bc4713eddb819 @seancorfield seancorfield committed Oct 18, 2012
Showing with 11 additions and 1 deletion.
  1. +4 −1 src/somnium/congomongo/coerce.clj
  2. +7 −0 test/somnium/test/congomongo.clj
View
5 src/somnium/congomongo/coerce.clj
@@ -2,7 +2,7 @@
(:use [clojure.data.json :only [json-str read-json]]
[clojure.core.incubator :only [seqable?]])
(:import [clojure.lang IPersistentMap IPersistentVector Keyword]
- [java.util Map List]
+ [java.util Map List Set]
[com.mongodb DBObject BasicDBObject BasicDBList]
[com.mongodb.gridfs GridFSFile]
[com.mongodb.util JSON]))
@@ -75,6 +75,9 @@
List
(clojure->mongo [^List o] (map clojure->mongo o))
+ Set
+ (clojure->mongo [^Set o] (set (map clojure->mongo o)))
+
Object
(clojure->mongo [o] o)
View
7 test/somnium/test/congomongo.clj
@@ -151,6 +151,13 @@
(is (not (contains? res :key)))
(is (= 4 (:value res))))))
+(deftest can-insert-sets
+ (with-test-mongo
+ (insert! :test_col {:num-set #{1 2 3}
+ :kw-set #{:key1 :key2}})
+ (is (= [1 2 3] (:num-set (fetch-one :test_col))))
+ (is (= ["key1" "key2"] (:kw-set (fetch-one :test_col))))))
+
(deftest collection-existence
(with-test-mongo
(insert! :notbogus {:foo "bar"})

0 comments on commit 6abfee3

Please sign in to comment.