summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGarren Smith <garren.smith@gmail.com>2018-09-05 11:55:13 +0200
committerRobert Newson <rnewson@apache.org>2018-09-07 16:37:16 +0100
commit8de56b5910f71c6e0ff6a2acc6f182b98642853e (patch)
tree70980a9521ba471a38a64d49afa74c154a5dc719
parent2d7e6813c567e47d54168745bafe76a6411e689b (diff)
downloadcouchdb-8de56b5910f71c6e0ff6a2acc6f182b98642853e.tar.gz
validate partitioned design docs
-rw-r--r--src/couch_mrview/src/couch_mrview.erl34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/couch_mrview/src/couch_mrview.erl b/src/couch_mrview/src/couch_mrview.erl
index 1b1a06b74..32e4b3957 100644
--- a/src/couch_mrview/src/couch_mrview.erl
+++ b/src/couch_mrview/src/couch_mrview.erl
@@ -175,16 +175,44 @@ join([H|T], Sep, Acc) ->
join(T, Sep, [Sep, H | Acc]).
+validate_partitioned_ddoc(#doc{} = DDoc) ->
+ {DDocProps} = DDoc#doc.body,
+ Banned = [
+ <<"shows">>,
+ <<"rewrites">>,
+ <<"lists">>,
+ <<"updates">>,
+ <<"filters">>,
+ <<"validate_doc_update">>
+ ],
+ validate_partitioned_ddoc(DDocProps, Banned).
+
+
+validate_partitioned_ddoc([], _Banned) ->
+ ok;
+validate_partitioned_ddoc([{Key, _Value} | Rest], Banned) ->
+ case lists:member(Key, Banned) of
+ true ->
+ Msg = [<<"`">>, Key, <<"` cannot be used in a partitioned design doc">>],
+ throw({invalid_design_doc, ?l2b(Msg)});
+ false ->
+ validate_partitioned_ddoc(Rest, Banned)
+ end.
+
+
validate(DbName, DDoc) ->
ok = validate_ddoc_fields(DDoc#doc.body),
DbPartitioned = mem3:is_partitioned(DbName),
DDocPartitioned = get_partitioned_opt(DDoc#doc.body, DbPartitioned),
- if
- not DbPartitioned andalso DDocPartitioned ->
+
+ case {DbPartitioned, DDocPartitioned} of
+ {true, true} ->
+ validate_partitioned_ddoc(DDoc);
+ {false, true} ->
throw({invalid_design_doc,
<<"partitioned option cannot be true in a "
"non-partitioned database.">>});
- true ->
+ {_, _} ->
ok
end,
GetName = fun