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/13 14:58:24 UTC

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

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

 ##########
 File path: src/mango/src/mango_selector.erl
 ##########
 @@ -573,27 +573,26 @@ match({[_, _ | _] = _Props} = Sel, _Value, _Cmp) ->
 % Returns true if Selector requires all  
 % fields in RequiredFields to exist in any matching documents.
 
+% Creates a tuple list with all fields initially set to false
 % For each condition in the selector, check
 % whether the field is in RequiredFields.
-% If it is, remove it from RequiredFields and continue
-% until we match then all or run out of selector to
+% If it is, set the field to true and continue
+% until run out of selector to
 % match against.
 
-has_required_fields(Selector, RequiredFields) ->
-    Remainder = has_required_fields_int(Selector, RequiredFields),
+has_required_fields(Selector, Fields) ->
+    RequiredFields = [{Field, false} || Field <- Fields],
+    RequiredFields1 = has_required_fields_int(Selector, RequiredFields),
+    Remainder = [Result || {_Field, Result} <- RequiredFields1, Result =:= false],
 
 Review comment:
   Style nit, but this is a bit subtle in that the intent isn't immediately obvious. `lists:all/2` seems like a better fit here.
   
   ```suggestion
       lists:all(fun({_, Status}) -> Status end, RequiredFields1).
   ```

----------------------------------------------------------------
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