summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul J. Davis <paul.joseph.davis@gmail.com>2019-06-10 14:35:11 -0500
committerPaul J. Davis <paul.joseph.davis@gmail.com>2019-07-31 11:55:30 -0500
commitda85a5c574d6bd376bf02905bdf358979f3a60a5 (patch)
tree8f00113b37f4ebe2c9ef0b8e239a8d855d13a057
parentf7a790ea72dbe5c89658de93816e66a5ed3ec10d (diff)
downloadcouchdb-da85a5c574d6bd376bf02905bdf358979f3a60a5.tar.gz
Fix validate_doc_update when recreating a document
This fixes the behavior when validating a document update that is recreating a previously deleted document. Before this fix we were sending a document body with `"_deleted":true` as the existing document. However, CouchDB behavior expects the previous document passed to VDU's to be `null` in this case.
-rw-r--r--src/fabric/src/fabric2_db.erl7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/fabric/src/fabric2_db.erl b/src/fabric/src/fabric2_db.erl
index acd473f12..48e50f11c 100644
--- a/src/fabric/src/fabric2_db.erl
+++ b/src/fabric/src/fabric2_db.erl
@@ -1196,8 +1196,13 @@ prep_and_validate(Db, NewDoc, PrevRevInfo) ->
_ -> false
end,
+ WasDeleted = case PrevRevInfo of
+ not_found -> false;
+ #{deleted := D} -> D
+ end,
+
PrevDoc = case HasStubs orelse (HasVDUs and not IsDDoc) of
- true when PrevRevInfo /= not_found ->
+ true when PrevRevInfo /= not_found, not WasDeleted ->
case fabric2_fdb:get_doc_body(Db, NewDoc#doc.id, PrevRevInfo) of
#doc{} = PDoc -> PDoc;
{not_found, _} -> nil