You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2018/11/12 23:51:28 UTC

[GitHub] tonysun83 commented on a change in pull request #1718: Perform explicit $exists:false on Index validation

tonysun83 commented on a change in pull request #1718: Perform explicit $exists:false on Index validation
URL: https://github.com/apache/couchdb/pull/1718#discussion_r232851798
 
 

 ##########
 File path: src/mango/src/mango_selector.erl
 ##########
 @@ -608,35 +607,42 @@ has_required_fields_int([{[{<<"$and">>, Args}]}], RequiredFields)
 % must be covered by all children.
 has_required_fields_int([{[{<<"$or">>, Args}]} | Rest], RequiredFields) 
         when is_list(Args) ->
-    Remainder0 = lists:foldl(fun(Arg, Acc) ->
+    RequiredFields0 = lists:foldl(fun(Arg, Acc) ->
         % for each child test coverage against the full
         % set of required fields
-        Remainder = has_required_fields_int(Arg, RequiredFields),
+        ProcessedFields = has_required_fields_int(Arg, RequiredFields),
 
         % collect the remaining fields across all children
-        Acc ++ Remainder
+        Acc ++ ProcessedFields
     end, [], Args),
 
     % remove duplicate fields
-    Remainder1 = lists:usort(Remainder0),
-    has_required_fields_int(Rest, Remainder1);
+    RequiredFields1 = lists:usort(RequiredFields0),
+    has_required_fields_int(Rest, RequiredFields1);
 
 % Handle $and operator where it has peers. Required fields
 % can be covered by any child.
 has_required_fields_int([{[{<<"$and">>, Args}]} | Rest], RequiredFields) 
         when is_list(Args) ->
-    Remainder = has_required_fields_int(Args, RequiredFields),
-    has_required_fields_int(Rest, Remainder);
+    RequiredFields1 = has_required_fields_int(Args, RequiredFields),
+    has_required_fields_int(Rest, RequiredFields1);
 
 has_required_fields_int([{[{Field, Cond}]} | Rest], RequiredFields) ->
-    case Cond of
+    RequiredFields1 = case {Cond, lists:keymember(Field, 1, RequiredFields)} of
         % $exists:false is a special case - this is the only operator
         % that explicitly does not require a field to exist
-        {[{<<"$exists">>, false}]} ->
-            has_required_fields_int(Rest, RequiredFields);
-        _ ->
-            has_required_fields_int(Rest, lists:delete(Field, RequiredFields))
-    end.
+        {{[{<<"$exists">>, false}]}, true} ->
+            % case lists:keymember(Field, 1, RequiredFields) of
 
 Review comment:
   let's remove these extraneous comments

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services