You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by jc...@apache.org on 2008/12/16 22:19:04 UTC
svn commit: r727156 - in /couchdb/trunk: THANKS
share/www/script/couch_tests.js src/couchdb/couch_httpd_view.erl
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 <wi...@gmail.com>
* Antony Blakey <an...@gmail.com>
* Yoan Blanc <yo...@gmail.com>
+ * Paul Carey <pa...@gmail.com>
* Benoit Chesneau <bc...@gmail.com>
* Paul Joseph Davis <pa...@gmail.com>
* Michael Gottesman <go...@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.