couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jch...@apache.org
Subject svn commit: r727156 - in /couchdb/trunk: THANKS share/www/script/couch_tests.js src/couchdb/couch_httpd_view.erl
Date Tue, 16 Dec 2008 21:19:04 GMT
Author: jchris
Date: Tue Dec 16 13:19:03 2008
New Revision: 727156

URL: http://svn.apache.org/viewvc?rev=727156&view=rev
Log:
fix COUCHDB-177. thanks Paul Carey and Paul Davis

Modified:
    couchdb/trunk/THANKS
    couchdb/trunk/share/www/script/couch_tests.js
    couchdb/trunk/src/couchdb/couch_httpd_view.erl

Modified: couchdb/trunk/THANKS
URL: http://svn.apache.org/viewvc/couchdb/trunk/THANKS?rev=727156&r1=727155&r2=727156&view=diff
==============================================================================
--- couchdb/trunk/THANKS (original)
+++ couchdb/trunk/THANKS Tue Dec 16 13:19:03 2008
@@ -10,6 +10,7 @@
  * William Beh <willbeh@gmail.com>
  * Antony Blakey <antony.blakey@gmail.com>
  * Yoan Blanc <yoan.blanc@gmail.com>
+ * Paul Carey <paul.p.carey@gmail.com>
  * Benoit Chesneau <bchesneau@gmail.com>
  * Paul Joseph Davis <paul.joseph.davis@gmail.com>
  * Michael Gottesman <gottesmm@reed.edu>

Modified: couchdb/trunk/share/www/script/couch_tests.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/couch_tests.js?rev=727156&r1=727155&r2=727156&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/couch_tests.js [utf-8] (original)
+++ couchdb/trunk/share/www/script/couch_tests.js [utf-8] Tue Dec 16 13:19:03 2008
@@ -1344,6 +1344,15 @@
     }
     T(db.save(designDoc).ok);
 
+    // Test that missing keys work too
+    var keys = [101,30,15,37,50]
+    var reduce = db.view("test/summate",{group:true},keys).rows;
+    T(reduce.length == keys.length-1); // 101 is missing
+    for(var i=0; i<reduce.length; i++) {
+      T(keys.indexOf(reduce[i].key) != -1);
+      T(reduce[i].key == reduce[i].value);
+    }
+
     // First, the goods:
     var keys = [10,15,30,37,50];
     var rows = db.view("test/all_docs",{},keys).rows;
@@ -1356,7 +1365,7 @@
     T(reduce.length == keys.length);
     for(var i=0; i<reduce.length; i++) {
       T(keys.indexOf(reduce[i].key) != -1);
-      T(rows[i].key == rows[i].value);
+      T(reduce[i].key == reduce[i].value);
     }
 
     // Test that invalid parameter combinations get rejected

Modified: couchdb/trunk/src/couchdb/couch_httpd_view.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_view.erl?rev=727156&r1=727155&r2=727156&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_view.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_view.erl Tue Dec 16 13:19:03 2008
@@ -153,10 +153,10 @@
     send_chunk(Resp, "{\"rows\":["),
     lists:foldl(
         fun(Key, AccSeparator) ->
-            {ok, _} = couch_view:fold_reduce(View, Dir, {Key, StartDocId}, 
+            {ok, {NewAcc, _, _}} = couch_view:fold_reduce(View, Dir, {Key, StartDocId}, 
                 {Key, EndDocId}, GroupRowsFun, RespFun, 
                 {AccSeparator, Skip, Count}),
-            "," % Switch to comma
+            NewAcc % Switch to comma
         end,
     "", Keys), % Start with no comma
     send_chunk(Resp, "]}"),
@@ -456,4 +456,4 @@
         end_json_response(Resp);
     Error ->
         throw(Error)
-    end.
\ No newline at end of file
+    end.



Mime
View raw message