ksnavely commented on a change in pull request #1783: fix empty queries
URL: https://github.com/apache/couchdb/pull/1783#discussion_r241985200
##########
File path: src/mango/test/06-basic-text-test.py
##########
@@ -438,6 +438,41 @@ def test_regex(self):
assert docs[0]["user_id"] == 2
assert docs[1]["user_id"] == 10
+ def test_empty(self):
+ resp = self.db.find({}, explain=True)
+ self.assertEqual(resp["index"]["type"], "special")
+
+ def test_empty_array_or(self):
+ resp = self.db.find({"$or": []}, explain=True)
+ self.assertEqual(resp["index"]["type"], "text")
+ docs = self.db.find({"$or": []})
+ assert len(docs) == 0
+
+ def test_empty_array_or_with_age(self):
+ resp = self.db.find({"age": 22, "$or": []}, explain=True)
+ self.assertEqual(resp["index"]["type"], "text")
+ docs = self.db.find({"age": 22, "$or": []})
+ assert len(docs) == 1
+
+ def test_empty_array_and_with_age(self):
+ resp = self.db.find({"age": 22, "$and": [{"b": {"$all":[]}}]},
+ explain=True)
+ self.assertEqual(resp["index"]["type"], "text")
+ docs = self.db.find({"age": 22, "$and": []})
+ assert len(docs) == 1
+
+ def test_empty_arrays_complex(self):
+ resp = self.db.find({"$or": [], "a": {"$in" : []}}, explain=True)
Review comment:
"simple" combinations of empty queries will also short-circuit to no
execution right?
----------------------------------------------------------------
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