tonysun83 commented on a change in pull request #863: Ffix exists false when 
field is explicitly defined
URL: https://github.com/apache/couchdb/pull/863#discussion_r142560185
 
 

 ##########
 File path: src/mango/test/07-text-custom-field-list-test.py
 ##########
 @@ -160,3 +164,35 @@ def test_all_match(self):
         })
         assert len(docs) == 1
         assert docs[0]["user_id"] == 10
+
+    def test_exists_field(self):
+        docs = self.db.find({"exists_field": {"$exists": True}})
+        assert len(docs) == 2
+        for d in docs:
+            assert d["user_id"] in (7, 8)
+
+        docs = self.db.find({"exists_field": {"$exists": False}})
+        assert len(docs) == len(user_docs.DOCS) - 2
+        for d in docs:
+            assert d["user_id"] not in (7, 8)
+
+    def test_exists_array(self):
+        docs = self.db.find({"exists_array": {"$exists": True}})
+        assert len(docs) == 2
+        for d in docs:
+            assert d["user_id"] in (9, 10)
+
+        docs = self.db.find({"exists_array": {"$exists": False}})
+        assert len(docs) == len(user_docs.DOCS) - 2
+        for d in docs:
+            assert d["user_id"] not in (9, 10)
+
+    def test_exists_object(self):
+        docs = self.db.find({"exists_object.should": {"$exists": True}})
+        assert len(docs) == 1
+        assert docs[0]["user_id"] == 11
+
+        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
 
 Review comment:
   whitespace missing after !=
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to