summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBessenyei Balázs Donát <bessbd@apache.org>2020-10-07 19:36:49 +0200
committerJuanjo Rodriguez <jjrodrig@gmail.com>2020-10-13 11:40:40 +0200
commitfa0aff9332c7260a4d5e50b354386f39308cbf17 (patch)
treea1889ee73c1e3db7cd70806a287714a7b33b1306
parent52575df88ae4b268502c3a4b5e4ca36a46842389 (diff)
downloadcouchdb-fa0aff9332c7260a4d5e50b354386f39308cbf17.tar.gz
Fix boolean POST to view-like endpoints
-rw-r--r--src/couch_mrview/src/couch_mrview_http.erl8
-rw-r--r--test/elixir/test/all_docs_test.exs18
-rw-r--r--test/elixir/test/view_test.exs12
3 files changed, 34 insertions, 4 deletions
diff --git a/src/couch_mrview/src/couch_mrview_http.erl b/src/couch_mrview/src/couch_mrview_http.erl
index e1ba9d656..dcb401d68 100644
--- a/src/couch_mrview/src/couch_mrview_http.erl
+++ b/src/couch_mrview/src/couch_mrview_http.erl
@@ -539,15 +539,15 @@ parse_param(Key, Val, Args, IsDecoded) ->
Args#mrargs{stable=true, update=lazy};
"stale" ->
throw({query_parse_error, <<"Invalid value for `stale`.">>});
- "stable" when Val == "true" orelse Val == <<"true">> ->
+ "stable" when Val == "true" orelse Val == <<"true">> orelse Val == true ->
Args#mrargs{stable=true};
- "stable" when Val == "false" orelse Val == <<"false">> ->
+ "stable" when Val == "false" orelse Val == <<"false">> orelse Val == false ->
Args#mrargs{stable=false};
"stable" ->
throw({query_parse_error, <<"Invalid value for `stable`.">>});
- "update" when Val == "true" orelse Val == <<"true">> ->
+ "update" when Val == "true" orelse Val == <<"true">> orelse Val == true ->
Args#mrargs{update=true};
- "update" when Val == "false" orelse Val == <<"false">> ->
+ "update" when Val == "false" orelse Val == <<"false">> orelse Val == false ->
Args#mrargs{update=false};
"update" when Val == "lazy" orelse Val == <<"lazy">> ->
Args#mrargs{update=lazy};
diff --git a/test/elixir/test/all_docs_test.exs b/test/elixir/test/all_docs_test.exs
index 0dff2a445..5523565a4 100644
--- a/test/elixir/test/all_docs_test.exs
+++ b/test/elixir/test/all_docs_test.exs
@@ -427,4 +427,22 @@ defmodule AllDocsTest do
%{"rows" => rows} = resp
Enum.map(rows, fn row -> row["id"] end)
end
+
+ @tag :with_db
+ test "POST boolean", context do
+ db_name = context[:db_name]
+
+ resp = Couch.post("/#{db_name}/_bulk_docs", body: %{docs: create_docs(0..3)})
+ assert resp.status_code in [201, 202]
+
+ resp = Couch.post(
+ "/#{db_name}/_all_docs",
+ body: %{
+ :stable => true,
+ :update => true
+ }
+ )
+
+ assert resp.status_code == 200
+ end
end
diff --git a/test/elixir/test/view_test.exs b/test/elixir/test/view_test.exs
index f768cef16..bfe28b573 100644
--- a/test/elixir/test/view_test.exs
+++ b/test/elixir/test/view_test.exs
@@ -141,4 +141,16 @@ defmodule ViewTest do
assert resp.status_code == 200
assert length(Map.get(resp, :body)["rows"]) == 1
end
+
+ test "POST with boolean parameter", context do
+ resp = Couch.post(
+ "/#{context[:db_name]}/_design/map/_view/some",
+ body: %{
+ :stable => true,
+ :update => true
+ }
+ )
+
+ assert resp.status_code == 200
+ end
end