[ 
https://issues.apache.org/jira/browse/COUCHDB-188?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12779736#action_12779736
 ] 

Paul Joseph Davis commented on COUCHDB-188:
-------------------------------------------


couchTests.custom_test = function(debug) {
  var db = new CouchDB("test_suite_db", {"X-Couch-Full-Commit":"false"});
  db.deleteDb(); 
  db.createDb(); 

  var results = db.bulkSave([{_id: 'foo'}]); 
  var orig_rev = results[0].rev; 
  results = db.bulkSave([
    {_id: 'foo', _rev: "2-eec205a9d413992850a6e32678485900"},
    {_id: 'foo', _rev: orig_rev, _deleted: true}
  ]);
  alert(JSON.stringify(results));
  T(results[0].error === undefined);
  T(results[1].error === undefined);
};

Slightly interesting, the order of updates is backwards. Also, it works if we 
specify what the _rev would be after the delete call. 

> _bulk_docs fails when deleting and adding a doc with the same id
> ----------------------------------------------------------------
>
>                 Key: COUCHDB-188
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-188
>             Project: CouchDB
>          Issue Type: Bug
>          Components: Database Core
>    Affects Versions: 0.9
>         Environment: CouchDB revision 730414.
>            Reporter: Matt Goodall
>             Fix For: 0.9
>
>
> CouchDB returns a "412 Precondition Failed" when the list of changes sent to 
> _bulk_docs deletes a document and later creates a document with the same id 
> as the deleted document:
>     {"docs": [
>         {"_id": "docid", "_rev": "<rev>", "_deleted": true},
>         {"_id": "docid"}
>         ]}
> Once fixed, the response JSON document  will return the same docid twice in 
> the list but it's presumably ordered consistently with the request data so 
> any client should be able to understand the response.
> Demonstrating the problem using curl is easy enough:
> $ curl -X PUT http://localhost:5984/test
> {"ok":true}
> $ curl -X PUT -d "{}" http://localhost:5984/test/docid
> {"ok":true,"id":"docid","rev":"4140747751"}
> $ curl -X POST -d '{"docs": [{"_id": "docid", "_rev": "4140747751", 
> "_deleted": true}, {"_id": "docid"}]}' http://localhost:5984/test/_bulk_docs
> {"error":"conflict","reason":"Document update conflict."}
> Note: this is likely related to COUCHDB-172.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to