From 856d5b1ed17ad621543c2ef0d6d369dee9f206b0 Mon Sep 17 00:00:00 2001 From: Jan Lehnardt Date: Sun, 14 Nov 2010 23:16:35 +0000 Subject: Allow reduce=false parameter in map-only views. Patch by Jason Smith. Closes COUCHDB-881. git-svn-id: https://svn.apache.org/repos/asf/couchdb/branches/1.0.x@1035098 13f79535-47bb-0310-9956-ffa450edef68 --- share/www/script/test/view_errors.js | 25 ++++++++++++++++++++++--- src/couchdb/couch_httpd_view.erl | 2 ++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/share/www/script/test/view_errors.js b/share/www/script/test/view_errors.js index a211c061..c05000b7 100644 --- a/share/www/script/test/view_errors.js +++ b/share/www/script/test/view_errors.js @@ -74,9 +74,6 @@ couchTests.view_errors = function(debug) { T(e.error == "query_parse_error"); } - // reduce=false on map views doesn't work, so group=true will - // never throw for temp reduce views. - var designDoc = { _id:"_design/test", language: "javascript", @@ -104,6 +101,15 @@ couchTests.view_errors = function(debug) { db.view("test/no_reduce", {group: true}); T(0 == 1); } catch(e) { + T(db.last_req.status == 400); + T(e.error == "query_parse_error"); + } + + try { + db.view("test/no_reduce", {group_level: 1}); + T(0 == 1); + } catch(e) { + T(db.last_req.status == 400); T(e.error == "query_parse_error"); } @@ -115,10 +121,23 @@ couchTests.view_errors = function(debug) { T(e.error == "query_parse_error"); } + db.view("test/no_reduce", {reduce: false}); + TEquals(200, db.last_req.status, "reduce=false for map views (without" + + " group or group_level) is allowed"); + try { db.view("test/with_reduce", {group: true, reduce: false}); T(0 == 1); } catch(e) { + T(db.last_req.status == 400); + T(e.error == "query_parse_error"); + } + + try { + db.view("test/with_reduce", {group_level: 1, reduce: false}); + T(0 == 1); + } catch(e) { + T(db.last_req.status == 400); T(e.error == "query_parse_error"); } diff --git a/src/couchdb/couch_httpd_view.erl b/src/couchdb/couch_httpd_view.erl index e1a0dfad..cb387d1b 100644 --- a/src/couchdb/couch_httpd_view.erl +++ b/src/couchdb/couch_httpd_view.erl @@ -365,6 +365,8 @@ validate_view_query(group_level, Value, Args) -> end; validate_view_query(inclusive_end, Value, Args) -> Args#view_query_args{inclusive_end=Value}; +validate_view_query(reduce, false, Args) -> + Args; validate_view_query(reduce, _, Args) -> case Args#view_query_args.view_type of map -> -- cgit v1.2.3