summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--share/www/script/test/view_errors.js8
-rw-r--r--src/couchdb/couch_db.hrl1
-rw-r--r--src/couchdb/couch_httpd_view.erl23
3 files changed, 29 insertions, 3 deletions
diff --git a/share/www/script/test/view_errors.js b/share/www/script/test/view_errors.js
index aa698f4d..60ccca59 100644
--- a/share/www/script/test/view_errors.js
+++ b/share/www/script/test/view_errors.js
@@ -81,6 +81,14 @@ couchTests.view_errors = function(debug) {
}
try {
+ db.view("test/no_reduce", {reduce: true});
+ T(0 == 1);
+ } catch(e) {
+ T(db.last_req.status == 400);
+ T(e.error == "query_parse_error");
+ }
+
+ try {
db.view("test/with_reduce", {group: true, reduce: false});
T(0 == 1);
} catch(e) {
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 ->