couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Goodall <matt.good...@gmail.com>
Subject _bulk_docs inconsistency
Date Mon, 06 Apr 2009 17:42:40 GMT
Hi,

I came across an inconsistency with _bulk_docs when creating new
documents, i.e. calling _bulk_docs against an empty database.

It seems that it's ok to create a new document from a JSON object that
includes a _rev ... unless the JSON also has inline attachments:

$ curl -X "POST" -d
"{\"docs\":[{\"_id\":\"a\",\"_rev\":\"1-3864900503\"}]}"
"http://localhost:5984/test/_bulk_docs"
[{"id":"a","rev":"2-1966182305"}]
$ curl -X "POST" -d
"{\"docs\":[{\"_id\":\"b\",\"_rev\":\"2-3530543911\",\"_attachments\":{\"hello.txt\":{\"content_type\":\"text/plain\",\"data\":\"SGVsbG8K\"}}}]}"
"http://localhost:5984/test/_bulk_docs"
[{"id":"b","error":"conflict","reason":"Document update conflict."}]

I'll write JS tests for this and create a ticket but, at this stage,
I'm not sure what the correct behaviour is:

1. CouchDB should not allow a document to be created from JSON
containing a _rev at all.
2. JSON that includes _rev and _attachements should work.

Assuming the _rev is allowed, should CouchDB then:

1. Completely ignore the _rev in the JSON and assign a new 1-based
rev, i.e. 1-abc in, 1-def out.
2. Allow the _rev in the JSON and assign a new, incremented rev, i.e.
1-abc in, 2-def out.
3. Accept the _rev in the JSON as-is, i.e. 1-abc in, 1-abc out. (I'm
not expecting this one to be correct!)

- Matt

Mime
View raw message