This is an automated email from the ASF dual-hosted git repository. rnewson pushed a commit to branch user-partitioned-dbs-6 in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 90a0028a676b0b04025b6afbcd895fb0a4389452 Author: Garren Smith <[email protected]> AuthorDate: Thu Sep 6 12:13:25 2018 +0200 move view validation to chttp_view for partition checks --- src/chttpd/src/chttpd_view.erl | 20 ++++++++++++++++++++ src/couch_mrview/src/couch_mrview_util.erl | 14 -------------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/chttpd/src/chttpd_view.erl b/src/chttpd/src/chttpd_view.erl index 3743e6d..e56be0c 100644 --- a/src/chttpd/src/chttpd_view.erl +++ b/src/chttpd/src/chttpd_view.erl @@ -121,6 +121,7 @@ handle_partition_view_req(#httpd{method='POST', Args0 = couch_mrview_http:parse_params(Req, Keys), Args1 = couch_mrview_util:set_extra(Args0, partition, Partition), Args2 = couch_mrview_util:set_extra(Args1, partitioned, true), + ok = check_partition_restrictions(Args2), design_doc_view_int(Req, Db, DDoc, ViewName, Args2); _ -> throw({ @@ -135,12 +136,31 @@ handle_partition_view_req(#httpd{method='GET', Args = couch_mrview_http:parse_params(Req, Keys), Args1 = couch_mrview_util:set_extra(Args, partition, Partition), Args2 = couch_mrview_util:set_extra(Args1, partitioned, true), + ok = check_partition_restrictions(Args2), design_doc_view_int(Req, Db, DDoc, ViewName, Args2); handle_partition_view_req(Req, _Db, _DDoc, _Pk) -> chttpd:send_method_not_allowed(Req, "GET"). +check_partition_restrictions(#mrargs{} = Args) -> + Restrictions = [ + {<<"include_docs">>, Args#mrargs.include_docs, true}, + {<<"stable">>, Args#mrargs.stable, true}, + {<<"conflicts">>, Args#mrargs.conflicts, true} + ], + lists:foreach(fun ({Param, Field, Value}) -> + case Field =:= Value of + true -> + Msg = [<<"`">>, Param, <<"=true` is not supported in this view.">>], + throw({bad_request, ?l2b(Msg)}); + false -> + ok + end + end, Restrictions), + ok. + + -ifdef(TEST). -include_lib("eunit/include/eunit.hrl"). diff --git a/src/couch_mrview/src/couch_mrview_util.erl b/src/couch_mrview/src/couch_mrview_util.erl index 518b11b..f2866f5 100644 --- a/src/couch_mrview/src/couch_mrview_util.erl +++ b/src/couch_mrview/src/couch_mrview_util.erl @@ -607,20 +607,6 @@ validate_args(Args) -> mrverror(<<"`partition` parameter is not supported in this view.">>) end, - case {Partitioned, Args#mrargs.conflicts} of - {true, true} -> - mrverror(<<"`conflicts=true` is not supported in this view.">>); - {_, _} -> - ok - end, - - case {Partitioned, Args#mrargs.stable} of - {true, true} -> - mrverror(<<"`stable=true` is not supported in this view.">>); - {_, _} -> - ok - end, - Args1 = case {Style, Partitioned, Partition} of {all_docs, true, undefined} -> Args;
