couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r1170298 - in /couchdb/trunk: THANKS share/www/script/test/update_documents.js src/couchdb/couch_httpd_show.erl
Date Tue, 13 Sep 2011 18:53:38 GMT
Author: jan
Date: Tue Sep 13 18:53:38 2011
New Revision: 1170298

URL: http://svn.apache.org/viewvc?rev=1170298&view=rev
Log:
Allow slashes in doc ids in URLs to _update handlers.

This mirrors the behaviour of the _show API.

Patch by Christopher Bonhage.

Closes COUCHDB-1229

Modified:
    couchdb/trunk/THANKS
    couchdb/trunk/share/www/script/test/update_documents.js
    couchdb/trunk/src/couchdb/couch_httpd_show.erl

Modified: couchdb/trunk/THANKS
URL: http://svn.apache.org/viewvc/couchdb/trunk/THANKS?rev=1170298&r1=1170297&r2=1170298&view=diff
==============================================================================
--- couchdb/trunk/THANKS (original)
+++ couchdb/trunk/THANKS Tue Sep 13 18:53:38 2011
@@ -87,5 +87,6 @@ suggesting improvements or submitting ch
  * Dave Cottlehuber <dave@muse.net.nz>
  * Trond Norbye <trond.norbye@gmail.com>
  * Alexander Shorin <kxepal@gmail.com>
+ * Christopher Bonhage <queezey@me.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=1170298&r1=1170297&r2=1170298&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/update_documents.js (original)
+++ couchdb/trunk/share/www/script/test/update_documents.js Tue Sep 13 18:53:38 2011
@@ -165,4 +165,18 @@ couchTests.update_documents = function(d
   T(xhr.status == 200);
   T(xhr.responseText.length == 32);
 
+  // COUCHDB-1229 - allow slashes in doc ids for update handlers
+  // /db/_design/doc/_update/handler/doc/id
+
+  var doc = {
+      _id:"with/slash",
+      counter:1
+  };
+  db.save(doc);
+  xhr = CouchDB.request("PUT", "/test_suite_db/_design/update/_update/bump-counter/with/slash");
+  TEquals(201, xhr.status, "should return a 200 status");
+  TEquals("<h1>bumped it!</h1>", xhr.responseText, "should report bumping");
+
+  var doc = db.open("with/slash");
+  TEquals(2, doc.counter, "counter should be 2");
 };

Modified: couchdb/trunk/src/couchdb/couch_httpd_show.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_show.erl?rev=1170298&r1=1170297&r2=1170298&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_show.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_show.erl Tue Sep 13 18:53:38 2011
@@ -106,13 +106,15 @@ get_fun_key(DDoc, Type, Name) ->
 %     send_method_not_allowed(Req, "POST,PUT,DELETE,ETC");
     
 handle_doc_update_req(#httpd{
-        path_parts=[_, _, _, _, UpdateName, DocId]
+        path_parts=[_, _, _, _, UpdateName, DocId|Rest]
     }=Req, Db, DDoc) ->
-    Doc = try couch_httpd_db:couch_doc_open(Db, DocId, nil, [conflicts])
+    DocParts = [DocId|Rest],
+    DocId1 = ?l2b(string:join([?b2l(P)|| P <- DocParts], "/")),
+    Doc = try couch_httpd_db:couch_doc_open(Db, DocId1, nil, [conflicts])
     catch
       _ -> nil
     end,
-    send_doc_update_response(Req, Db, DDoc, UpdateName, Doc, DocId);
+    send_doc_update_response(Req, Db, DDoc, UpdateName, Doc, DocId1);
 
 handle_doc_update_req(#httpd{
         path_parts=[_, _, _, _, UpdateName]



Mime
View raw message