couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tonysu...@apache.org
Subject [2/2] couchdb-mango git commit: Add filter test
Date Tue, 08 Dec 2015 21:11:29 GMT
Add filter test

BugzID: 43810


Project: http://git-wip-us.apache.org/repos/asf/couchdb-mango/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-mango/commit/db3116c4
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-mango/tree/db3116c4
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-mango/diff/db3116c4

Branch: refs/heads/2913-port-missed-commits
Commit: db3116c48780ad09064281ebc4e374b497781767
Parents: f1f816b
Author: Tony Sun <tony.sun@cloudant.com>
Authored: Wed Jan 28 10:28:49 2015 -0800
Committer: Tony Sun <tony.sun@cloudant.com>
Committed: Tue Dec 8 13:04:52 2015 -0800

----------------------------------------------------------------------
 src/mango_cursor_text.erl              |  1 +
 test/07-text-custom-field-list-test.py | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/db3116c4/src/mango_cursor_text.erl
----------------------------------------------------------------------
diff --git a/src/mango_cursor_text.erl b/src/mango_cursor_text.erl
index 9f2beeb..920f6f7 100644
--- a/src/mango_cursor_text.erl
+++ b/src/mango_cursor_text.erl
@@ -54,6 +54,7 @@ create(Db, Indexes, Selector, Opts0) ->
     Limit = erlang:min(DreyfusLimit, couch_util:get_value(limit, Opts, 50)),
     Skip = couch_util:get_value(skip, Opts, 0),
     Fields = couch_util:get_value(fields, Opts, all_fields),
+
     {ok, #cursor{
         db = Db,
         index = Index,

http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/db3116c4/test/07-text-custom-field-list-test.py
----------------------------------------------------------------------
diff --git a/test/07-text-custom-field-list-test.py b/test/07-text-custom-field-list-test.py
index 8a8a5f8..73d870b 100644
--- a/test/07-text-custom-field-list-test.py
+++ b/test/07-text-custom-field-list-test.py
@@ -118,3 +118,24 @@ class CustomFieldsTest(mango.UserDocsTextTests):
             raise Exception("Should have thrown an HTTPError")
         except:
             return
+
+    def test_filtered_search_fields(self):
+        docs = self.db.find({"age": 22}, fields = ["age", "location.state"])
+        assert len(docs) == 1
+        assert docs == [{"age": 22, "location": {"state": "Missouri"}}]
+
+        docs = self.db.find({"age": 22}, fields = ["age", "Random Garbage"])
+        assert len(docs) == 1
+        assert docs == [{"age": 22}]
+
+        docs = self.db.find({"age": 22}, fields = ["favorites"])
+        assert len(docs) == 1
+        assert docs == [{"favorites": ["Lisp", "Erlang", "Python"]}]
+
+        docs = self.db.find({"age": 22}, fields = ["favorites.[]"])
+        assert len(docs) == 1
+        assert docs == [{}]
+
+        docs = self.db.find({"age": 22}, fields = ["all_fields"])
+        assert len(docs) == 1
+        assert docs == [{}]


Mime
View raw message