couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r766347 - in /couchdb/trunk: share/www/script/test/view_errors.js src/couchdb/couch_db.hrl src/couchdb/couch_httpd_view.erl
Date Sat, 18 Apr 2009 16:16:26 GMT
Author: davisp
Date: Sat Apr 18 16:16:26 2009
New Revision: 766347

URL: http://svn.apache.org/viewvc?rev=766347&view=rev
Log:
Fixes COUCHDB-322

Specifying reduce=true now returns a 400 error when the view has no reduce
function.


Modified:
    couchdb/trunk/share/www/script/test/view_errors.js
    couchdb/trunk/src/couchdb/couch_db.hrl
    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=766347&r1=766346&r2=766347&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/view_errors.js (original)
+++ couchdb/trunk/share/www/script/test/view_errors.js Sat Apr 18 16:16:26 2009
@@ -81,6 +81,14 @@
   }
   
   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) {

Modified: couchdb/trunk/src/couchdb/couch_db.hrl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_db.hrl?rev=766347&r1=766346&r2=766347&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_db.hrl (original)
+++ couchdb/trunk/src/couchdb/couch_db.hrl Sat Apr 18 16:16:26 2009
@@ -155,6 +155,7 @@
     skip = 0,
     group_level = 0,
     reduce = true,
+    req_reduce = false,
     inclusive_end=true, % aka a closed-interval
     include_docs = false
 }).

Modified: couchdb/trunk/src/couchdb/couch_httpd_view.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_view.erl?rev=766347&r1=766346&r2=766347&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_view.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_view.erl Sat Apr 18 16:16:26 2009
@@ -364,9 +364,15 @@
         {"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 @@
             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 ->



Mime
View raw message