couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fdman...@apache.org
Subject svn commit: r1070625 - in /couchdb/trunk: share/www/script/test/all_docs.js src/couchdb/couch_httpd_db.erl
Date Mon, 14 Feb 2011 19:44:00 GMT
Author: fdmanana
Date: Mon Feb 14 19:44:00 2011
New Revision: 1070625

URL: http://svn.apache.org/viewvc?rev=1070625&view=rev
Log:
_all_docs rows must not deleted include documents

After COUCHDB-1061, when POSTing to _all_docs?include_docs=true with
the body "keys" option, deleted documents were part part of the output.
The "doc" property of each _all_docs row should have the value 'null'
for all deleted documents (when ?include_docs=true).
A test was added to help prevent this from happening again.


Modified:
    couchdb/trunk/share/www/script/test/all_docs.js
    couchdb/trunk/src/couchdb/couch_httpd_db.erl

Modified: couchdb/trunk/share/www/script/test/all_docs.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/all_docs.js?rev=1070625&r1=1070624&r2=1070625&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/all_docs.js (original)
+++ couchdb/trunk/share/www/script/test/all_docs.js Mon Feb 14 19:44:00 2011
@@ -86,6 +86,13 @@ couchTests.all_docs = function(debug) {
   T(changes.results[2].doc);
   T(changes.results[2].doc._deleted);
 
+  rows = db.allDocs({include_docs: true}, ["1"]).rows;
+  TEquals(1, rows.length);
+  TEquals("1", rows[0].key);
+  TEquals("1", rows[0].id);
+  TEquals(true, rows[0].value.deleted);
+  TEquals(null, rows[0].doc);
+
   // add conflicts
   var conflictDoc1 = {
     _id: "3", _rev: "2-aa01552213fafa022e6167113ed01087", value: "X"

Modified: couchdb/trunk/src/couchdb/couch_httpd_db.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_db.erl?rev=1070625&r1=1070624&r2=1070625&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_db.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_db.erl Mon Feb 14 19:44:00 2011
@@ -559,7 +559,12 @@ all_docs_send_json_view_row(Resp, Db, KV
 all_docs_view_row_obj(_Db, {{DocId, error}, Value}, _IncludeDocs) ->
     {[{key, DocId}, {error, Value}]};
 all_docs_view_row_obj(Db, {_KeyDocId, DocInfo}, true) ->
-    {all_docs_row(DocInfo) ++ couch_httpd_view:doc_member(Db, DocInfo)};
+    case DocInfo of
+    #doc_info{revs = [#rev_info{deleted = true} | _]} ->
+        {all_docs_row(DocInfo) ++ [{doc, null}]};
+    _ ->
+        {all_docs_row(DocInfo) ++ couch_httpd_view:doc_member(Db, DocInfo)}
+    end;
 all_docs_view_row_obj(_Db, {_KeyDocId, DocInfo}, _IncludeDocs) ->
     {all_docs_row(DocInfo)}.
 



Mime
View raw message