Return-Path: Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: (qmail 88017 invoked from network); 16 Jun 2010 18:20:50 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 16 Jun 2010 18:20:50 -0000 Received: (qmail 76654 invoked by uid 500); 16 Jun 2010 18:20:49 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 76613 invoked by uid 500); 16 Jun 2010 18:20:48 -0000 Mailing-List: contact dev-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list dev@couchdb.apache.org Received: (qmail 76593 invoked by uid 99); 16 Jun 2010 18:20:48 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Jun 2010 18:20:48 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Jun 2010 18:20:46 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id o5GIKNud026949 for ; Wed, 16 Jun 2010 18:20:24 GMT Message-ID: <15353077.33901276712423064.JavaMail.jira@thor> Date: Wed, 16 Jun 2010 14:20:22 -0400 (EDT) From: "Zachary Zolton (JIRA)" To: dev@couchdb.apache.org Subject: [jira] Updated: (COUCHDB-802) Doc ID should auto-generate if not provided, before sending to _update function [PATCH] In-Reply-To: <18748166.25581276673783203.JavaMail.jira@thor> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/COUCHDB-802?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Zachary Zolton updated COUCHDB-802: ----------------------------------- Attachment: COUCHDB-802-with-test.diff Will this test suffice? (^_^) > Doc ID should auto-generate if not provided, before sending to _update function [PATCH] > --------------------------------------------------------------------------------------- > > Key: COUCHDB-802 > URL: https://issues.apache.org/jira/browse/COUCHDB-802 > Project: CouchDB > Issue Type: Bug > Components: HTTP Interface, JavaScript View Server > Affects Versions: 0.11 > Environment: Linux > Reporter: Jason Smith > Priority: Minor > Fix For: 0.11.1 > > Attachments: COUCHDB-802-with-test.diff, new_id.diff > > Original Estimate: 24h > Remaining Estimate: 24h > > The main bug is this: _show and _update functions should be able to mimic the standard HTTP/JSON API. A common pattern people are moving to is rewriting to _show and _update, so the client thinks it is hitting normal couch, however additional logic happens (e.g. auto-timestamping). > Unfortunately, _update cannot return an auto-generated ID for POST to /db/_design/ddoc/_update. The semantics should match POST to /db/ -- If an _id is provided, use that; otherwise auto-generate one. The best an _update function can do now is Math.random() or similar; however one loses the advantage of sequential UUID generation from couch's internals. > The fix is for couch to send a random UUID if the update URL did not include the final /Id component. The function itself in the view server can decide whether to use it. Assuming that change, the update function could at least be capable of duplicating the direct API using the following Javascript logic: > function(doc, req) { > if(doc && doc._id == req.id) { > // To be pedantic, I could confirm req.method == "PUT" > log("I am an update by id"); > } else if(doc === null && req.id) { > if(req.method == "POST") { > log("I am a create, id was auto-generated"); > } else if(req.method == "PUT") { > log("I am a create, id was supplied by client"); > } > } > } -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.