summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Lehnardt <jan@apache.org>2010-02-28 02:48:32 +0000
committerJan Lehnardt <jan@apache.org>2010-02-28 02:48:32 +0000
commit12417e6faecc72fe53d858390f9c84c379b8baed (patch)
treea4268dc90249b6965658cf9def9cb1619c8115e4
parent879e8a5add3502a826726fcf884cce0a61e03694 (diff)
treat deleted docs as nonexistant docs
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@917104 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--share/www/script/test/show_documents.js17
-rw-r--r--src/couchdb/couch_httpd_show.erl1
2 files changed, 18 insertions, 0 deletions
diff --git a/share/www/script/test/show_documents.js b/share/www/script/test/show_documents.js
index f49c1f1f..e06bcadc 100644
--- a/share/www/script/test/show_documents.js
+++ b/share/www/script/test/show_documents.js
@@ -54,6 +54,13 @@ couchTests.show_documents = function(debug) {
json : req
}
}),
+ "show-deleted" : stringFun(function(doc, req) {
+ if(doc) {
+ return doc._id;
+ } else {
+ return "No doc " + req.id;
+ }
+ }),
"render-error" : stringFun(function(doc, req) {
return noSuchVariable;
}),
@@ -393,5 +400,15 @@ couchTests.show_documents = function(debug) {
T(xhr.responseText == "Hey Dude");
TEquals("Yeah", xhr.getResponseHeader("X-Couch-Test-Header"), "header should be cool");
TEquals("Oh Yeah!", xhr.getResponseHeader("X-Couch-Test-Header-Awesome"), "header should be cool");
+
+ // test deleted docs
+ var doc = {_id:"testdoc",foo:1};
+ db.save(doc);
+ var xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/show-deleted/testdoc");
+ TEquals("testdoc", xhr.responseText, "should return 'testdoc'");
+
+ db.deleteDoc(doc);
+ var xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/show-deleted/testdoc");
+ TEquals("No doc testdoc", xhr.responseText, "should return 'no doc testdoc'");
};
diff --git a/src/couchdb/couch_httpd_show.erl b/src/couchdb/couch_httpd_show.erl
index 18f24e85..72c6bae1 100644
--- a/src/couchdb/couch_httpd_show.erl
+++ b/src/couchdb/couch_httpd_show.erl
@@ -31,6 +31,7 @@
maybe_open_doc(Db, DocId) ->
case catch couch_httpd_db:couch_doc_open(Db, DocId, nil, [conflicts]) of
{not_found, missing} -> nil;
+ {not_found,deleted} -> nil;
Doc -> Doc
end.
handle_doc_show_req(#httpd{