You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by "jaydoane (via GitHub)" <gi...@apache.org> on 2023/03/09 06:50:12 UTC

[GitHub] [couchdb] jaydoane commented on a diff in pull request #4414: Mutual exclusive: key, keys, start_key and end_key

jaydoane commented on code in PR #4414:
URL: https://github.com/apache/couchdb/pull/4414#discussion_r1130554459


##########
src/couch_mrview/src/couch_mrview_http.erl:
##########
@@ -525,34 +530,147 @@ parse_param(Key, Val, Args, IsDecoded) ->
         "reduce" ->
             Args#mrargs{reduce = parse_boolean(Val)};
         "key" when IsDecoded ->
-            Args#mrargs{start_key = Val, end_key = Val};
+            case Args#mrargs.start_key =:= undefined andalso Args#mrargs.end_key =:= undefined of
+                true ->
+                    Args#mrargs{start_key = Val, end_key = Val};
+                _ ->
+                    throw(
+                        {query_parse_error,
+                            <<"`key(s)` is incompatible with `start_key` and `end_key`">>}
+                    )
+            end;

Review Comment:
   While logically correct, I find this kind of boilerplate can be hard to easily understand.
   
   I tried to refactor this file here: https://github.com/apache/couchdb/commit/f1777aac244f46d3e9cf6521f0bb6f1726f8e638 to make it easier to understand. What do you think?



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

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org