diff options
-rw-r--r-- | share/www/script/test/attachments.js | 13 | ||||
-rw-r--r-- | src/couchdb/couch_db.erl | 8 |
2 files changed, 13 insertions, 8 deletions
diff --git a/share/www/script/test/attachments.js b/share/www/script/test/attachments.js index ce7a5d05..4b6fa58e 100644 --- a/share/www/script/test/attachments.js +++ b/share/www/script/test/attachments.js @@ -170,7 +170,18 @@ couchTests.attachments= function(debug) { docs.push(doc) } - db.bulkSave(docs); + var saved = db.bulkSave(docs); + // now delete the docs, and while we are looping over them, remove the + // '_rev' field so we can re-create after deletion. + var to_up = []; + for (i=0;i<saved.length;i++) { + to_up.push({'_id': saved[i]['id'], '_rev': saved[i]['rev'], '_deleted': true}); + delete docs[i]._rev; + } + // delete them. + var saved2 = db.bulkSave(to_up); + // re-create them + var saved3 = db.bulkSave(docs); var before = db.info().disk_size; diff --git a/src/couchdb/couch_db.erl b/src/couchdb/couch_db.erl index 4e64846c..aff5b743 100644 --- a/src/couchdb/couch_db.erl +++ b/src/couchdb/couch_db.erl @@ -316,13 +316,7 @@ prep_and_validate_update(Db, #doc{id=Id,revs={RevStart, Revs}}=Doc, [] -> % new doc, and we have existing revs. % reuse existing deleted doc - if OldFullDocInfo#full_doc_info.deleted -> - % existing docs are deletions - #doc_info{revs=[#rev_info{rev={Pos, DelRevId}}|_]} = - couch_doc:to_doc_info(OldFullDocInfo), - Doc2 = Doc#doc{revs={Pos, [DelRevId]}}, - {validate_doc_update(Db, Doc2, fun() -> nil end), Doc2}; - AllowConflict -> + if OldFullDocInfo#full_doc_info.deleted orelse AllowConflict -> {validate_doc_update(Db, Doc, fun() -> nil end), Doc}; true -> {conflict, Doc} |