couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r1035097 - in /couchdb/trunk: share/www/script/test/view_errors.js src/couchdb/couch_httpd_view.erl
Date Sun, 14 Nov 2010 23:16:17 GMT
Author: jan
Date: Sun Nov 14 23:16:17 2010
New Revision: 1035097

URL: http://svn.apache.org/viewvc?rev=1035097&view=rev
Log:
Allow reduce=false parameter in map-only views.

Patch by Jason Smith.

Closes COUCHDB-881.

Modified:
    couchdb/trunk/share/www/script/test/view_errors.js
    couchdb/trunk/src/couchdb/couch_httpd_view.erl

Modified: couchdb/trunk/share/www/script/test/view_errors.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/view_errors.js?rev=1035097&r1=1035096&r2=1035097&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/view_errors.js (original)
+++ couchdb/trunk/share/www/script/test/view_errors.js Sun Nov 14 23:16:17 2010
@@ -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");
       }
 

Modified: couchdb/trunk/src/couchdb/couch_httpd_view.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_view.erl?rev=1035097&r1=1035096&r2=1035097&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_view.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_view.erl Sun Nov 14 23:16:17 2010
@@ -387,6 +387,8 @@ validate_view_query(group_level, Value, 
     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 ->



Mime
View raw message