summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjiangph <jiangph@cn.ibm.com>2019-01-28 22:32:50 +0800
committerjiangph <jiangph@cn.ibm.com>2019-01-28 22:32:50 +0800
commit5c1bb7e9816cd44b332e022b1c34158f2cc62385 (patch)
treec8ef27f1f6d76e289f3123b1863849f17bba4897
parent0c591905e1a31db0e6c34f35dd0b66c72ad03db0 (diff)
downloadcouchdb-5c1bb7e9816cd44b332e022b1c34158f2cc62385.tar.gz
Support search with limit using POST method
-rw-r--r--src/dreyfus_httpd.erl2
-rw-r--r--test/elixir/test/partition_search_test.exs22
2 files changed, 23 insertions, 1 deletions
diff --git a/src/dreyfus_httpd.erl b/src/dreyfus_httpd.erl
index a1a5cb398..f9cdb7ce3 100644
--- a/src/dreyfus_httpd.erl
+++ b/src/dreyfus_httpd.erl
@@ -312,7 +312,7 @@ parse_json_index_param(<<"bookmark">>, Value) ->
parse_json_index_param(<<"sort">>, Value) ->
[{sort, Value}];
parse_json_index_param(<<"limit">>, Value) ->
- [{limit, ?JSON_DECODE(Value)}];
+ [{limit, Value}];
parse_json_index_param(<<"stale">>, <<"ok">>) ->
[{stale, ok}];
parse_json_index_param(<<"include_docs">>, Value) when is_boolean(Value) ->
diff --git a/test/elixir/test/partition_search_test.exs b/test/elixir/test/partition_search_test.exs
index 98b23b508..f0d32bd17 100644
--- a/test/elixir/test/partition_search_test.exs
+++ b/test/elixir/test/partition_search_test.exs
@@ -108,6 +108,28 @@ defmodule PartitionSearchTest do
assert resp.status_code == 400
end
+ @tag :with_db
+ test "Works with limit using POST for on non-partitioned db", context do
+ db_name = context[:db_name]
+ create_search_docs(db_name)
+ create_ddoc(db_name)
+
+ url = "/#{db_name}/_design/library/_search/books"
+ resp = Couch.post(url, body: %{:q => "some:field", :limit => 1})
+ assert resp.status_code == 200
+ end
+
+ @tag :with_partitioned_db
+ test "Works with limit using POST for partitioned db", context do
+ db_name = context[:db_name]
+ create_search_docs(db_name)
+ create_ddoc(db_name)
+
+ url = "/#{db_name}/_partition/foo/_design/library/_search/books"
+ resp = Couch.post(url, body: %{:q => "some:field", :limit => 1, :partition=> "true"})
+ assert resp.status_code == 200
+ end
+
@tag :with_partitioned_db
test "Cannot do global query with partition view", context do
db_name = context[:db_name]