You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2020/06/12 17:54:14 UTC
[couchdb] 04/10: fix(doc): delete
This is an automated email from the ASF dual-hosted git repository.
jan pushed a commit to branch feat/access-3.x
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit f81828e1cc0b3ba2ca749f82f52ddd86fea1905a
Author: Jan Lehnardt <ja...@apache.org>
AuthorDate: Fri Jun 12 17:02:55 2020 +0200
fix(doc): delete
---
src/chttpd/src/chttpd_db.erl | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/src/chttpd/src/chttpd_db.erl b/src/chttpd/src/chttpd_db.erl
index 44d96fd..0e56bcb 100644
--- a/src/chttpd/src/chttpd_db.erl
+++ b/src/chttpd/src/chttpd_db.erl
@@ -922,12 +922,21 @@ view_cb(Msg, Acc) ->
couch_mrview_http:view_cb(Msg, Acc).
db_doc_req(#httpd{method='DELETE'}=Req, Db, DocId) ->
- % check for the existence of the doc to handle the 404 case.
- OldDoc = couch_doc_open(Db, DocId, nil, [{user_ctx, Req#httpd.user_ctx}]),
- NewRevs = couch_doc:parse_rev(chttpd:qs_value(Req, "rev")),
- NewBody = {[{<<"_deleted">>}, true]},
- NewDoc = OldDoc#doc{revs=NewRevs, body=NewBody},
- send_updated_doc(Req, Db, DocId, couch_doc_from_req(Req, Db, DocId, NewDoc));
+ couch_doc_open(Db, DocId, nil, [{user_ctx, Req#httpd.user_ctx}]),
+ case chttpd:qs_value(Req, "rev") of
+ undefined ->
+ Body = {[{<<"_deleted">>,true}]};
+ Rev ->
+ Body = {[{<<"_rev">>, ?l2b(Rev)},{<<"_deleted">>,true}]}
+ end,
+ send_updated_doc(Req, Db, DocId, couch_doc_from_req(Req, Db, DocId, Body));
+
+ % % check for the existence of the doc to handle the 404 case.
+ % OldDoc = couch_doc_open(Db, DocId, nil, [{user_ctx, Req#httpd.user_ctx}]),
+ % NewRevs = couch_doc:parse_rev(chttpd:qs_value(Req, "rev")),
+ % NewBody = {[{<<"_deleted">>}, true]},
+ % NewDoc = OldDoc#doc{revs=NewRevs, body=NewBody},
+ % send_updated_doc(Req, Db, DocId, couch_doc_from_req(Req, Db, DocId, NewDoc));
db_doc_req(#httpd{method='GET', mochi_req=MochiReq}=Req, Db, DocId) ->
#doc_query_args{