summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Lehnardt <jan@apache.org>2020-04-22 11:19:41 +0200
committerGitHub <noreply@github.com>2020-04-22 11:19:41 +0200
commitb035651a4f26dbec9636228c3f1ea73f77880e5c (patch)
tree851cbf293dcd84d3031966a37b8ca30d8cbc3785
parent419d51bebfbb6d98d055ab63c42e9c79f96f8acf (diff)
parenta8413bce72fb03f9a56d251fcb2c9198953d4bbf (diff)
downloadcouchdb-fix/2797/setup-unknown-error.tar.gz
Merge branch 'master' into fix/2797/setup-unknown-errorfix/2797/setup-unknown-error
-rw-r--r--rebar.config.script2
-rw-r--r--src/mango/src/mango_selector.erl4
-rw-r--r--src/mango/test/21-empty-selector-tests.py24
3 files changed, 26 insertions, 4 deletions
diff --git a/rebar.config.script b/rebar.config.script
index 408ad3d48..bfca5c84e 100644
--- a/rebar.config.script
+++ b/rebar.config.script
@@ -153,7 +153,7 @@ DepDescs = [
{docs, {url, "https://github.com/apache/couchdb-documentation"},
{tag, "3.0.0"}, [raw]},
{fauxton, {url, "https://github.com/apache/couchdb-fauxton"},
- {tag, "v1.2.2"}, [raw]},
+ {tag, "v1.2.3"}, [raw]},
%% Third party deps
{folsom, "folsom", {tag, "CouchDB-0.8.3"}},
{hyper, "hyper", {tag, "CouchDB-2.2.0-6"}},
diff --git a/src/mango/src/mango_selector.erl b/src/mango/src/mango_selector.erl
index 3ea83c220..e884dc55c 100644
--- a/src/mango/src/mango_selector.erl
+++ b/src/mango/src/mango_selector.erl
@@ -421,7 +421,7 @@ match({[{<<"$not">>, Arg}]}, Value, Cmp) ->
not match(Arg, Value, Cmp);
match({[{<<"$all">>, []}]}, _, _) ->
- true;
+ false;
% All of the values in Args must exist in Values or
% Values == hd(Args) if Args is a single element list
% that contains a list.
@@ -506,7 +506,7 @@ match({[{<<"$gt">>, Arg}]}, Value, Cmp) ->
Cmp(Value, Arg) > 0;
match({[{<<"$in">>, []}]}, _, _) ->
- true;
+ false;
match({[{<<"$in">>, Args}]}, Values, Cmp) when is_list(Values)->
Pred = fun(Arg) ->
lists:foldl(fun(Value,Match) ->
diff --git a/src/mango/test/21-empty-selector-tests.py b/src/mango/test/21-empty-selector-tests.py
index beb222c85..31ad8e645 100644
--- a/src/mango/test/21-empty-selector-tests.py
+++ b/src/mango/test/21-empty-selector-tests.py
@@ -35,14 +35,36 @@ def make_empty_selector_suite(klass):
docs = self.db.find({"age": 22, "$or": []})
assert len(docs) == 1
+ def test_empty_array_in_with_age(self):
+ resp = self.db.find({"age": 22, "company": {"$in": []}}, explain=True)
+ self.assertEqual(resp["index"]["type"], klass.INDEX_TYPE)
+ docs = self.db.find({"age": 22, "company": {"$in": []}})
+ assert len(docs) == 0
+
def test_empty_array_and_with_age(self):
resp = self.db.find(
- {"age": 22, "$and": [{"b": {"$all": []}}]}, explain=True
+ {"age": 22, "$and": []}, explain=True
)
self.assertEqual(resp["index"]["type"], klass.INDEX_TYPE)
docs = self.db.find({"age": 22, "$and": []})
assert len(docs) == 1
+ def test_empty_array_all_age(self):
+ resp = self.db.find(
+ {"age": 22, "company": {"$all": []}}, explain=True
+ )
+ self.assertEqual(resp["index"]["type"], klass.INDEX_TYPE)
+ docs = self.db.find({"age": 22, "company": {"$all": []}})
+ assert len(docs) == 0
+
+ def test_empty_array_nested_all_with_age(self):
+ resp = self.db.find(
+ {"age": 22, "$and": [{"company": {"$all": []}}]}, explain=True
+ )
+ self.assertEqual(resp["index"]["type"], klass.INDEX_TYPE)
+ docs = self.db.find( {"age": 22, "$and": [{"company": {"$all": []}}]})
+ assert len(docs) == 0
+
def test_empty_arrays_complex(self):
resp = self.db.find({"$or": [], "a": {"$in": []}}, explain=True)
self.assertEqual(resp["index"]["type"], klass.INDEX_TYPE)