Author: jchris Date: Wed Jun 16 21:14:06 2010 New Revision: 955389 URL: http://svn.apache.org/viewvc?rev=955389&view=rev Log: provide a uuid to update functions (and all other functions) that they can use to create new docs. closes COUCHDB-802. Thanks Jason Smith, Zachary Zolton, and Dmitry Unkovsky.
Modified: couchdb/trunk/THANKS couchdb/trunk/share/www/script/test/update_documents.js couchdb/trunk/src/couchdb/couch_httpd_external.erl Modified: couchdb/trunk/THANKS URL: http://svn.apache.org/viewvc/couchdb/trunk/THANKS?rev=955389&r1=955388&r2=955389&view=diff ============================================================================== --- couchdb/trunk/THANKS (original) +++ couchdb/trunk/THANKS Wed Jun 16 21:14:06 2010 @@ -58,5 +58,8 @@ suggesting improvements or submitting ch * Timothy Smith <t...@couch.io> * Martin Haaà <martinha...@gmx.net> * Hans Ulrich Niedermann <h...@n-dimensional.de> + * Jason Smith <j...@proven-corporation.com> + * Dmitry Unkovsky <oil.cray...@gmail.com> + * Zachary Zolton <zachary.zol...@gmail.com> For a list of authors see the `AUTHORS` file. Modified: couchdb/trunk/share/www/script/test/update_documents.js URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/update_documents.js?rev=955389&r1=955388&r2=955389&view=diff ============================================================================== --- couchdb/trunk/share/www/script/test/update_documents.js (original) +++ couchdb/trunk/share/www/script/test/update_documents.js Wed Jun 16 21:14:06 2010 @@ -72,6 +72,9 @@ couchTests.update_documents = function(d }; return [doc, resp]; + }), + "get-uuid" : stringFun(function(doc, req) { + return [null, req.uuid]; }) } }; @@ -123,7 +126,7 @@ couchTests.update_documents = function(d // bump counter xhr = CouchDB.request("PUT", "/test_suite_db/_design/update/_update/bump-counter/"+docid, { - headers : {"X-Couch-Full-Commit":"false"} + headers : {"X-Couch-Full-Commit":"true"} }); T(xhr.status == 201); T(xhr.responseText == "<h1>bumped it!</h1>"); @@ -144,7 +147,7 @@ couchTests.update_documents = function(d // parse xml xhr = CouchDB.request("PUT", "/test_suite_db/_design/update/_update/xml/"+docid, { - headers : {"X-Couch-Full-Commit":"false"}, + headers : {"X-Couch-Full-Commit":"true"}, "body" : '<xml><foo>bar</foo></xml>' }); T(xhr.status == 201); @@ -152,5 +155,10 @@ couchTests.update_documents = function(d doc = db.open(docid); T(doc.via_xml == "bar"); + + // Server provides UUID when POSTing without an ID in the URL + xhr = CouchDB.request("POST", "/test_suite_db/_design/update/_update/get-uuid/"); + T(xhr.status == 200); + T(xhr.responseText.length == 32); }; Modified: couchdb/trunk/src/couchdb/couch_httpd_external.erl URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_external.erl?rev=955389&r1=955388&r2=955389&view=diff ============================================================================== --- couchdb/trunk/src/couchdb/couch_httpd_external.erl (original) +++ couchdb/trunk/src/couchdb/couch_httpd_external.erl Wed Jun 16 21:14:06 2010 @@ -75,6 +75,7 @@ json_req_obj(#httpd{mochi_req=Req, % add headers... {[{<<"info">>, {Info}}, {<<"id">>, DocId}, + {<<"uuid">>, couch_uuids:new()}, {<<"method">>, Method}, {<<"path">>, Path}, {<<"query">>, json_query_keys(to_json_terms(Req:parse_qs()))},