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/06/06 14:41:07 UTC

[GitHub] nickva commented on a change in pull request #1376: Add fields to sort based on selector

nickva commented on a change in pull request #1376: Add fields to sort based on selector
URL: https://github.com/apache/couchdb/pull/1376#discussion_r193435442
 
 

 ##########
 File path: src/mango/src/mango_selector.erl
 ##########
 @@ -638,11 +639,110 @@ has_required_fields_int([{[{Field, Cond}]} | Rest], RequiredFields) ->
     end.
 
 
+% Returns true if a field in the selector is a constant value e.g. {a: {$eq: 1}}
+is_constant_field(Selector, Field) ->
+    is_constant_field_int(Selector, Field).
+
+
+is_constant_field_int({[]}, _Field) ->
+    false;
+
+is_constant_field_int(Selector, Field) when not is_list(Selector) ->
+    is_constant_field_int([Selector], Field);
+
+is_constant_field_int([], _Field) ->
+    false;
+
+is_constant_field_int([{[{<<"$and">>, Args}]}], Field) when is_list(Args) ->
+    lists:any(fun(Arg) -> is_constant_field_int(Arg, Field) end, Args);
 
 Review comment:
   lists:all instead of lists:any?

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