ksnavely commented on a change in pull request #1783: fix empty queries
URL: https://github.com/apache/couchdb/pull/1783#discussion_r241985137
##########
File path: src/mango/src/mango_selector.erl
##########
@@ -399,17 +399,25 @@ negate({[{Field, Cond}]}) ->
{[{Field, negate(Cond)}]}.
+% We need to treat an empty array as always true. This will be applied
+% for $or, $in, $all, $nin as well.
+match({[{<<"$and">>, []}]}, _, _) ->
+ true;
match({[{<<"$and">>, Args}]}, Value, Cmp) ->
Pred = fun(SubSel) -> match(SubSel, Value, Cmp) end,
lists:all(Pred, Args);
+match({[{<<"$or">>, []}]}, _, _) ->
+ true;
match({[{<<"$or">>, Args}]}, Value, Cmp) ->
Pred = fun(SubSel) -> match(SubSel, Value, Cmp) end,
lists:any(Pred, Args);
match({[{<<"$not">>, Arg}]}, Value, Cmp) ->
not match(Arg, Value, Cmp);
+match({[{<<"$all">>, []}]}, _, _) ->
+ true;
Review comment:
Is this a duplicate clause from L404?
----------------------------------------------------------------
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