diff options
author | Peng Hui Jiang <jiangphcn@apache.org> | 2019-01-29 08:10:47 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-29 08:10:47 +0800 |
commit | 0413baaac8ee6b4fb77084ab9548bb17f1702d69 (patch) | |
tree | c8ef27f1f6d76e289f3123b1863849f17bba4897 | |
parent | 0c591905e1a31db0e6c34f35dd0b66c72ad03db0 (diff) | |
parent | 5c1bb7e9816cd44b332e022b1c34158f2cc62385 (diff) | |
download | couchdb-0413baaac8ee6b4fb77084ab9548bb17f1702d69.tar.gz |
Merge pull request #40 from cloudant-labs/search-using-limit-with-post
Fix search with limit using POST method
-rw-r--r-- | src/dreyfus_httpd.erl | 2 | ||||
-rw-r--r-- | test/elixir/test/partition_search_test.exs | 22 |
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] |