This is an automated email from the ASF dual-hosted git repository.

tonysun83 pushed a commit to branch fix-explicit-exists-operator
in repository https://gitbox.apache.org/repos/asf/couchdb.git


The following commit(s) were added to refs/heads/fix-explicit-exists-operator 
by this push:
     new 81c1c91  make exists false same across all index types
81c1c91 is described below

commit 81c1c91fea1d17ef2c7bbe719e2a962ef25dd2e5
Author: Tony Sun <[email protected]>
AuthorDate: Mon Oct 16 22:36:23 2017 -0700

    make exists false same across all index types
---
 src/mango/src/mango_idx_text.erl                 |  3 ++-
 src/mango/test/07-text-custom-field-list-test.py | 26 ++++++++++++++++++------
 2 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/src/mango/src/mango_idx_text.erl b/src/mango/src/mango_idx_text.erl
index ac5c809..e7ce75f 100644
--- a/src/mango/src/mango_idx_text.erl
+++ b/src/mango/src/mango_idx_text.erl
@@ -325,8 +325,9 @@ indexable_fields(Fields, {op_or, Args}) when is_list(Args) 
->
 indexable_fields(Fields, {op_not, {ExistsQuery, Arg}}) when is_tuple(Arg) ->
     Fields0 = indexable_fields(Fields, ExistsQuery),
     indexable_fields(Fields0, Arg);
+% forces "$exists" : false to use _all_docs
 indexable_fields(Fields, {op_not, {ExistsQuery, false}}) ->
-    indexable_fields(Fields, ExistsQuery);
+    [];
 
 indexable_fields(Fields, {op_insert, Arg}) when is_binary(Arg) ->
     Fields;
diff --git a/src/mango/test/07-text-custom-field-list-test.py 
b/src/mango/test/07-text-custom-field-list-test.py
index 5b65d8d..921ae45 100644
--- a/src/mango/test/07-text-custom-field-list-test.py
+++ b/src/mango/test/07-text-custom-field-list-test.py
@@ -29,10 +29,7 @@ class CustomFieldsTest(mango.UserDocsTextTests):
             "name": "location.address.street",
             "type": "string"
         },
-        {"name": "name\\.first", "type": "string"},
-        {"name": "exists_field", "type": "string"},
-        {"name": "exists_array.[]", "type": "string"},
-        {"name": "exists_object.should", "type": "string"}
+        {"name": "name\\.first", "type": "string"}
     ]
 
     def test_basic(self):
@@ -165,6 +162,16 @@ class CustomFieldsTest(mango.UserDocsTextTests):
         assert len(docs) == 1
         assert docs[0]["user_id"] == 10
 
[email protected](mango.has_text_service(), "requires text service")
+class CustomFieldsExistsTest(mango.UserDocsTextTests):
+
+    FIELDS = [
+        {"name": "exists_field", "type": "string"},
+        {"name": "exists_array.[]", "type": "string"},
+        {"name": "exists_object.should", "type": "string"},
+        {"name": "twitter", "type": "string"}
+    ]
+
     def test_exists_field(self):
         docs = self.db.find({"exists_field": {"$exists": True}})
         assert len(docs) == 2
@@ -187,7 +194,7 @@ class CustomFieldsTest(mango.UserDocsTextTests):
         for d in docs:
             assert d["user_id"] not in (9, 10)
 
-    def test_exists_object(self):
+    def test_exists_object_member(self):
         docs = self.db.find({"exists_object.should": {"$exists": True}})
         assert len(docs) == 1
         assert docs[0]["user_id"] == 11
@@ -195,4 +202,11 @@ class CustomFieldsTest(mango.UserDocsTextTests):
         docs = self.db.find({"exists_object.should": {"$exists": False}})
         assert len(docs) == len(user_docs.DOCS) - 1
         for d in docs:
-            assert d["user_id"] !=11
+            assert d["user_id"] != 11
+
+    def test_exists_false_same_as_views(self):
+        docs = self.db.find({
+                "twitter": {"$exists": False}
+            })
+        for d in docs:
+            assert d["user_id"] not in (0, 1, 4, 13)

-- 
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].

Reply via email to