diff --git a/ChangeLog.md b/ChangeLog.md index 4ce5f8d..c5a3002 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,14 @@ ## Changes between 1.0.0-rc1 and 1.0.0-rc2 +### Query DSL no longer seq()s the cursor + +Query DSL will no longer apply `clojure.core/seq` to the underlying cursor, thus guaranteeing to return an empty +sequence when there are no results. This gives developers better control over what do they want to get back: +an empty sequence or nil. In the latter case, they will just manually apply `clojure.core/seq` to the +result. + + + ### More flexible monger.collection/ensure-index and monger.collection/create-index `monger.collection/ensure-index` and `monger.collection/ensure-index` now accept fields to index as a collection diff --git a/src/monger/query.clj b/src/monger/query.clj index 8e7d59e..9eb68a5 100644 --- a/src/monger/query.clj +++ b/src/monger/query.clj @@ -71,7 +71,7 @@ (when read-preference (.setReadPreference cursor read-preference)) (map (fn [x] (from-db-object x keywordize-fields)) - (seq cursor)))) + cursor))) ;; ;; API diff --git a/test/monger/test/querying_test.clj b/test/monger/test/querying_test.clj index 7cede5e..9573072 100644 --- a/test/monger/test/querying_test.clj +++ b/test/monger/test/querying_test.clj @@ -239,10 +239,15 @@ result3 (with-collection coll (find {}) (paginate :page 3 :per-page 3) + (sort { :title 1 })) + result4 (with-collection coll + (find {}) + (paginate :page 10 :per-page 3) (sort { :title 1 }))] (is (= [doc1 doc5 doc7] result1)) (is (= [doc2 doc6 doc4] result2)) - (is (= [doc3] result3)))) + (is (= [doc3] result3)) + (is (empty? result4)))) (deftest combined-querying-dsl-example1