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
commit 76792adf3068599c48f45521b4eb57f5bc5211ae 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 d81905f..369e2cd 100644 --- a/src/mango/src/mango_idx_text.erl +++ b/src/mango/src/mango_idx_text.erl @@ -329,8 +329,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]>.
