jjrodrig commented on pull request #3582:
URL: https://github.com/apache/couchdb/pull/3582#issuecomment-850499211


   Hi @hklarner, 
   
    I was checking this. It seems quite simple to introduce nesting the 
behaviour for the $size operator. I've been testing with these changes and 
seems to work. 
    
   ```diff
   --- a/src/mango/src/mango_selector.erl
   +++ b/src/mango/src/mango_selector.erl
   @@ -145,6 +145,8 @@ norm_ops({[{<<"$keyMapMatch">>, Arg}]}) ->
    
    norm_ops({[{<<"$size">>, Arg}]}) when is_integer(Arg), Arg >= 0 ->
        {[{<<"$size">>, Arg}]};
   +norm_ops({[{<<"$size">>, {_}=Arg}]}) ->
   +    {[{<<"$size">>, norm_ops(Arg)}]};
    norm_ops({[{<<"$size">>, Arg}]}) ->
        ?MANGO_ERROR({bad_arg, '$size', Arg});
    
   @@ -581,8 +583,10 @@ match({[{<<"$regex">>, Regex}]}, Value, _Cmp) when 
is_binary(Value) ->
    match({[{<<"$regex">>, _}]}, _Value, _Cmp) ->
        false;
    
   -match({[{<<"$size">>, Arg}]}, Values, _Cmp) when is_list(Values) ->
   +match({[{<<"$size">>, Arg}]}, Values, _Cmp) when is_list(Values), 
is_integer(Arg) ->
        length(Values) == Arg;
   +match({[{<<"$size">>, Arg}]}, Values, _Cmp) when is_list(Values) ->
   +    match(Arg, length(Values), _Cmp);
    match({[{<<"$size">>, _}]}, _Value, _Cmp) ->
        false;
   ```
   
   I hope this could help. 
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to