Return-Path: Delivered-To: apmail-incubator-couchdb-user-archive@locus.apache.org Received: (qmail 79134 invoked from network); 21 Oct 2008 16:37:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 21 Oct 2008 16:37:33 -0000 Received: (qmail 85369 invoked by uid 500); 21 Oct 2008 16:37:35 -0000 Delivered-To: apmail-incubator-couchdb-user-archive@incubator.apache.org Received: (qmail 85341 invoked by uid 500); 21 Oct 2008 16:37:35 -0000 Mailing-List: contact couchdb-user-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: couchdb-user@incubator.apache.org Delivered-To: mailing list couchdb-user@incubator.apache.org Received: (qmail 85330 invoked by uid 99); 21 Oct 2008 16:37:35 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Oct 2008 09:37:35 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [216.252.111.219] (HELO web57203.mail.re3.yahoo.com) (216.252.111.219) by apache.org (qpsmtpd/0.29) with SMTP; Tue, 21 Oct 2008 16:36:22 +0000 Received: (qmail 49966 invoked by uid 60001); 21 Oct 2008 16:35:18 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type:Message-ID; b=UoR0Qmq2xNRN0SbrXsvLpOQr+oV8iNtfLvQQ9nWjvR3LJz2xejDmoSP1peEucyK9PtPIgZKbbAGXu8VRJYybDaLhVkmm93GEd49d0v+EMr3KCWxUpDKk7Mvr6BiNTXKK040uu4YtRwZA7mbYMsYdQCuNaq4+ybG5H8nScUOB2og=; X-YMail-OSG: oibRrcUVM1kQstQqUvhDdVH_fIsMFKZAhLVMTsfWnJmbn5xP3zMCOXzDbjNYbo4toA-- Received: from [216.175.184.2] by web57203.mail.re3.yahoo.com via HTTP; Tue, 21 Oct 2008 09:35:18 PDT X-Mailer: YahooMailRC/1096.40 YahooMailWebService/0.7.247.3 Date: Tue, 21 Oct 2008 09:35:18 -0700 (PDT) From: Bradford Winfrey Subject: Re: 412 on update To: couchdb-user@incubator.apache.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1038450689-1224606918=:49195" Message-ID: <264235.49195.qm@web57203.mail.re3.yahoo.com> X-Virus-Checked: Checked by ClamAV on apache.org --0-1038450689-1224606918=:49195 Content-Type: text/plain; charset=us-ascii Hmm, I wonder if there is a test that accounts for that (it being an int rather than a string). If not, then I'm sure there is a good reason for it, maybe they allow alpha characters in the rev? Anyway, glad it helped out :) Brad ----- Original Message ---- From: Jonathan Moss To: couchdb-user@incubator.apache.org Sent: Tuesday, October 21, 2008 11:23:59 AM Subject: Re: 412 on update Thanks Bradford, That allowed me to track down the issue. It seems that when the PHP classes serialize the document in json for saving the _rev is cast to an integer. The rev numbers are often larger than the maximum integer value PHP supports and it therefore I end up with a -ve number and the revisions obviously don't match and I get a 412 - conflict. I then cast the value to a float which is done elsewhere in the library. This still resulted in a 412. So I looked at the raw put data from the request and compared it to the raw get data I got in the first place. The only difference was the by casting to a float _rev was encoded as: "_rev":123456789 whereas I received it as: "_rev":"123456789" By casting as a string just before json encoding I now get a much happier 201 status code during my testing. Should the server really be quibbling over the data type? Not a problem if it does but it was a difficult one to track down. Regards, Jon > I believe a 412 is a conflict, anyone care to prove me wrong? > > > > ----- Original Message ---- > From: Jonathan Moss > To: couchdb-user@incubator.apache.org > Sent: Tuesday, October 21, 2008 3:07:43 AM > Subject: Re: 412 on update > > >> Hi everyone, >> >> I am using the CouchDB PHP library (from >> http://couchprojects.googlecode.com/svn/trunk/libraries/php/) to >> communicate with the database an I am having some issues updating a >> design document. When I try to save the design document I receive a >> 412 HTTP status code. The code below is a simplification of what I am >> doing but should explain what I am trying to do. >> >> $objCouch = new Couch(array("host" => localhost, "port" => 5984)); >> $objDesignDoc = $objCouch->database($strDB)->get("_design/ADesignDoc"; >> $objFunction = new stdClass(); >> $objFunction->map = "function(doc){if(doc.Type = >> 'ANode'){emit(doc.Name, doc);}}"; >> $objDesignDoc->views->$strFunc = $objFunction; >> $objDesignDoc->save(); >> echo "Status: " . $objDesignDoc->lastStatusCode . "\n"; >> >> What does a 412 status code mean in this context and does anyone have >> any idea what I can do to fix it? >> >> Regards, >> Jon >> > > I should have mentioned I am using version 0.8.1 of CouchDB > > Thanks, > Jon > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com --0-1038450689-1224606918=:49195--