On Sun, Nov 21, 2010 at 1:23 PM, <[email protected]> wrote:
> Author: jan
> Date: Sun Nov 21 13:23:45 2010
> New Revision: 1037442
>
> URL: http://svn.apache.org/viewvc?rev=1037442&view=rev
> Log:
> Add ok:true to HTTP COPY response.
>
> Patch by Robert Dionne.
>
> Closes COUCHDB-903.
>
> Modified:
> couchdb/trunk/share/www/script/couch.js
> couchdb/trunk/share/www/script/test/copy_doc.js
> couchdb/trunk/src/couchdb/couch_httpd_db.erl
>
> Modified: couchdb/trunk/share/www/script/couch.js
> URL:
> http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/couch.js?rev=1037442&r1=1037441&r2=1037442&view=diff
> ==============================================================================
> --- couchdb/trunk/share/www/script/couch.js [utf-8] (original)
> +++ couchdb/trunk/share/www/script/couch.js [utf-8] Sun Nov 21 13:23:45 2010
> @@ -121,7 +121,7 @@ function CouchDB(name, httpHeaders) {
> CouchDB.maybeThrowError(this.last_req);
> var results = JSON.parse(this.last_req.responseText);
> for (var i = 0; i < docs.length; i++) {
> - if(results[i] && results[i].rev) {
> + if(results[i] && results[i].rev && results[i].ok) {
> docs[i]._rev = results[i].rev;
> }
> }
>
> Modified: couchdb/trunk/share/www/script/test/copy_doc.js
> URL:
> http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/copy_doc.js?rev=1037442&r1=1037441&r2=1037442&view=diff
> ==============================================================================
> --- couchdb/trunk/share/www/script/test/copy_doc.js (original)
> +++ couchdb/trunk/share/www/script/test/copy_doc.js Sun Nov 21 13:23:45 2010
> @@ -22,6 +22,8 @@ couchTests.copy_doc = function(debug) {
> headers: {"Destination":"doc_that_was_copied"}
> });
>
> + T(JSON.parse(xhr.responseText).ok);
> +
> T(xhr.status == 201);
> T(db.open("doc_that_was_copied").v == 1);
>
>
> Modified: couchdb/trunk/src/couchdb/couch_httpd_db.erl
> URL:
> http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_db.erl?rev=1037442&r1=1037441&r2=1037442&view=diff
> ==============================================================================
> --- couchdb/trunk/src/couchdb/couch_httpd_db.erl (original)
> +++ couchdb/trunk/src/couchdb/couch_httpd_db.erl Sun Nov 21 13:23:45 2010
> @@ -811,7 +811,7 @@ update_doc_result_to_json({{Id, Rev}, Er
> update_doc_result_to_json(#doc{id=DocId}, Result) ->
> update_doc_result_to_json(DocId, Result);
> update_doc_result_to_json(DocId, {ok, NewRev}) ->
> - {[{id, DocId}, {rev, couch_doc:rev_to_str(NewRev)}]};
> + {[{ok, true}, {id, DocId}, {rev, couch_doc:rev_to_str(NewRev)}]};
Jan, it's worth to notice that this line change not only affects the
output of the document COPY operation but also affects the output of
_bulk_docs.
> update_doc_result_to_json(DocId, Error) ->
> {_Code, ErrorStr, Reason} = couch_httpd:error_info(Error),
> {[{id, DocId}, {error, ErrorStr}, {reason, Reason}]}.
>
>
>
--
Filipe David Manana,
[email protected], [email protected]
"Reasonable men adapt themselves to the world.
Unreasonable men adapt the world to themselves.
That's why all progress depends on unreasonable men."