You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ko...@apache.org on 2019/09/24 18:59:38 UTC

[couchdb] branch remove-old-multiquery updated: Refactor based on review feedback

This is an automated email from the ASF dual-hosted git repository.

kocolosk pushed a commit to branch remove-old-multiquery
in repository https://gitbox.apache.org/repos/asf/couchdb.git


The following commit(s) were added to refs/heads/remove-old-multiquery by this push:
     new 10a3a59  Refactor based on review feedback
10a3a59 is described below

commit 10a3a591ad08eea3635a6bd686a9a77458d85df8
Author: Adam Kocoloski <ko...@apache.org>
AuthorDate: Tue Sep 24 14:56:05 2019 -0400

    Refactor based on review feedback
---
 src/chttpd/src/chttpd_view.erl | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/src/chttpd/src/chttpd_view.erl b/src/chttpd/src/chttpd_view.erl
index 42c3afd..0d3d86d 100644
--- a/src/chttpd/src/chttpd_view.erl
+++ b/src/chttpd/src/chttpd_view.erl
@@ -88,21 +88,15 @@ handle_view_req(#httpd{method='POST',
         path_parts=[_, _, _, _, ViewName]}=Req, Db, DDoc) ->
     chttpd:validate_ctype(Req, "application/json"),
     Props = couch_httpd:json_body_obj(Req),
-    Keys = couch_mrview_util:get_view_keys(Props),
-    Queries = couch_mrview_util:get_view_queries(Props),
-    case {Queries, Keys} of
-        {undefined, Keys} when is_list(Keys) ->
+    assert_no_queries_param(couch_mrview_util:get_view_queries(Props)),
+    case couch_mrview_util:get_view_keys(Props) of
+        Keys when is_list(Keys) ->
             couch_stats:increment_counter([couchdb, httpd, view_reads]),
             design_doc_view(Req, Db, DDoc, ViewName, Keys);
-        {undefined, undefined} ->
+        _ ->
             throw({
                 bad_request,
-                "POST body must contain `keys` field"
-            });
-        {_, _} ->
-            throw({
-                bad_request,
-                "The `queries` parameter is no longer supported at this endpoint"
+                "POST body must contain an array called `keys`"
             })
     end;
 
@@ -113,6 +107,14 @@ handle_temp_view_req(Req, _Db) ->
     Msg = <<"Temporary views are not supported in CouchDB">>,
     chttpd:send_error(Req, 410, gone, Msg).
 
+% See https://github.com/apache/couchdb/issues/2168
+assert_no_queries_param(undefined) ->
+    ok;
+assert_no_queries_param(_) ->
+    throw({
+        bad_request,
+        "The `queries` parameter is no longer supported at this endpoint"
+    }).
 
 
 -ifdef(TEST).