diff options
-rw-r--r-- | share/www/script/couch_tests.js | 9 | ||||
-rw-r--r-- | src/couchdb/couch_httpd.erl | 2 |
2 files changed, 8 insertions, 3 deletions
diff --git a/share/www/script/couch_tests.js b/share/www/script/couch_tests.js index c8884252..3863a380 100644 --- a/share/www/script/couch_tests.js +++ b/share/www/script/couch_tests.js @@ -328,7 +328,12 @@ var tests = { T(equals(results.rows[1], {key:["a","b"],value:20*i})); T(equals(results.rows[2], {key:["a", "b", "c"],value:10*i})); T(equals(results.rows[3], {key:["a", "b", "d"],value:10*i})); - + + // test to make sure group reduce and count params provide valid json + var results = db.query(map, reduce, {group: true, count: 2}); + T(equals(results.rows[0], {key: ["a"], value: 20*i})); + T(equals(results.rows.length, 2)); + //group by the first element in the key array var results = db.query(map, reduce, {group_level:1}); T(equals(results.rows[0], {key:["a"],value:70*i})); @@ -1146,7 +1151,7 @@ var tests = { db.deleteDb(); db.createDb(); if (debug) debugger; - var docs = makeDocs(0, 25); + var docs = makeDocs(0, 10); var saveResult = db.bulkSave(docs); T(saveResult.ok); diff --git a/src/couchdb/couch_httpd.erl b/src/couchdb/couch_httpd.erl index da3d7555..72e87b02 100644 --- a/src/couchdb/couch_httpd.erl +++ b/src/couchdb/couch_httpd.erl @@ -463,7 +463,7 @@ output_reduce_view(Req, View) -> fun(_Key, _Red, {AccSeparator,AccSkip,AccCount}) when AccSkip > 0 -> {ok, {AccSeparator,AccSkip-1,AccCount}}; (_Key, _Red, {AccSeparator,0,AccCount}) when AccCount == 0 -> - {stop,{AccSeparator,0,AccCount}}; + {ok, {AccSeparator,0,AccCount}}; (_Key, Red, {AccSeparator,0,AccCount}) when GroupLevel == 0 -> Json = lists:flatten(cjson:encode({obj, [{key, null}, {value, Red}]})), Resp:write_chunk(AccSeparator ++ Json), |