summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--THANKS1
-rw-r--r--share/www/script/couch_tests.js11
-rw-r--r--src/couchdb/couch_httpd_view.erl6
3 files changed, 14 insertions, 4 deletions
diff --git a/THANKS b/THANKS
index 4a3b66f3..532bc107 100644
--- a/THANKS
+++ b/THANKS
@@ -10,6 +10,7 @@ Some of these people are:
* 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>
diff --git a/share/www/script/couch_tests.js b/share/www/script/couch_tests.js
index 78b0c302..0ad6eee0 100644
--- a/share/www/script/couch_tests.js
+++ b/share/www/script/couch_tests.js
@@ -1344,6 +1344,15 @@ var tests = {
}
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 @@ var tests = {
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
diff --git a/src/couchdb/couch_httpd_view.erl b/src/couchdb/couch_httpd_view.erl
index f1c8616f..13842149 100644
--- a/src/couchdb/couch_httpd_view.erl
+++ b/src/couchdb/couch_httpd_view.erl
@@ -153,10 +153,10 @@ output_reduce_view(Req, View, QueryArgs, Keys) ->
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 @@ finish_view_fold(Req, TotalRows, FoldResult) ->
end_json_response(Resp);
Error ->
throw(Error)
- end. \ No newline at end of file
+ end.