diff options
author | John Christopher Anderson <jchris@apache.org> | 2010-06-16 21:14:06 +0000 |
---|---|---|
committer | John Christopher Anderson <jchris@apache.org> | 2010-06-16 21:14:06 +0000 |
commit | db16441b58fa57c14b5b814ba62d042455e6afd1 (patch) | |
tree | 42a84be481d6085c57867ff111b29d3a11db3f7c | |
parent | 78017574afd5796316a9f68cfc7f369e125fa36c (diff) |
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.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@955389 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | THANKS | 3 | ||||
-rw-r--r-- | share/www/script/test/update_documents.js | 12 | ||||
-rw-r--r-- | src/couchdb/couch_httpd_external.erl | 1 |
3 files changed, 14 insertions, 2 deletions
@@ -58,5 +58,8 @@ suggesting improvements or submitting changes. Some of these people are: * Timothy Smith <tim@couch.io> * Martin Haaß <MartinHaass@gmx.net> * Hans Ulrich Niedermann <hun@n-dimensional.de> + * Jason Smith <jhs@proven-corporation.com> + * Dmitry Unkovsky <oil.crayons@gmail.com> + * Zachary Zolton <zachary.zolton@gmail.com> For a list of authors see the `AUTHORS` file. diff --git a/share/www/script/test/update_documents.js b/share/www/script/test/update_documents.js index a8ec5901..da68d621 100644 --- a/share/www/script/test/update_documents.js +++ b/share/www/script/test/update_documents.js @@ -72,6 +72,9 @@ couchTests.update_documents = function(debug) { }; return [doc, resp]; + }), + "get-uuid" : stringFun(function(doc, req) { + return [null, req.uuid]; }) } }; @@ -123,7 +126,7 @@ couchTests.update_documents = function(debug) { // 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(debug) { // 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(debug) { 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); }; diff --git a/src/couchdb/couch_httpd_external.erl b/src/couchdb/couch_httpd_external.erl index 2ef2be35..07202934 100644 --- a/src/couchdb/couch_httpd_external.erl +++ b/src/couchdb/couch_httpd_external.erl @@ -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()))}, |