diff options
author | Paul Joseph Davis <davisp@apache.org> | 2009-04-18 16:16:35 +0000 |
---|---|---|
committer | Paul Joseph Davis <davisp@apache.org> | 2009-04-18 16:16:35 +0000 |
commit | 5442bdb4f36f6079c5e63b5ddd8486acd032e5ad (patch) | |
tree | bd29dfa9c194aa21eea45cdcf8289729fafdd3fb /src/couchdb | |
parent | 194975152f9c7d3d6f0c35c44a25415bc0fbafb6 (diff) |
Fixes COUCHDB-322
Specifying reduce=true now returns a 400 error when the view has no reduce
function.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@766347 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb')
-rw-r--r-- | src/couchdb/couch_db.hrl | 1 | ||||
-rw-r--r-- | src/couchdb/couch_httpd_view.erl | 23 |
2 files changed, 21 insertions, 3 deletions
diff --git a/src/couchdb/couch_db.hrl b/src/couchdb/couch_db.hrl index 6d9081a8..78087d86 100644 --- a/src/couchdb/couch_db.hrl +++ b/src/couchdb/couch_db.hrl @@ -155,6 +155,7 @@ skip = 0, group_level = 0, reduce = true, + req_reduce = false, inclusive_end=true, % aka a closed-interval include_docs = false }). diff --git a/src/couchdb/couch_httpd_view.erl b/src/couchdb/couch_httpd_view.erl index e0c3f631..4054eb05 100644 --- a/src/couchdb/couch_httpd_view.erl +++ b/src/couchdb/couch_httpd_view.erl @@ -364,9 +364,15 @@ parse_view_query(Req, Keys, IsReduce, IgnoreExtra) -> {"inclusive_end", "false"} -> Args#view_query_args{inclusive_end=false}; {"reduce", "true"} -> - Args#view_query_args{reduce=true}; + Args#view_query_args{ + reduce=true, + req_reduce=true + }; {"reduce", "false"} -> - Args#view_query_args{reduce=false}; + Args#view_query_args{ + reduce=false, + req_reduce=true + }; {"include_docs", Value} -> case Value of "true" -> @@ -401,7 +407,18 @@ parse_view_query(Req, Keys, IsReduce, IgnoreExtra) -> ok end; _ -> - ok + case QueryArgs#view_query_args.req_reduce of + true -> + case QueryArgs#view_query_args.reduce of + true -> + ErrMsg = <<"Bad URL parameter: reduce=true">>, + throw({query_parse_error, ErrMsg}); + _ -> + ok + end; + _ -> + ok + end end, case Keys of nil -> |