Return-Path: Delivered-To: apmail-incubator-couchdb-user-archive@locus.apache.org Received: (qmail 11634 invoked from network); 22 Oct 2008 22:06:52 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 22 Oct 2008 22:06:52 -0000 Received: (qmail 15600 invoked by uid 500); 22 Oct 2008 22:06:53 -0000 Delivered-To: apmail-incubator-couchdb-user-archive@incubator.apache.org Received: (qmail 15574 invoked by uid 500); 22 Oct 2008 22:06:53 -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 15563 invoked by uid 99); 22 Oct 2008 22:06:53 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Oct 2008 15:06:53 -0700 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [83.97.50.139] (HELO jan.prima.de) (83.97.50.139) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Oct 2008 22:05:41 +0000 Received: from [10.0.1.6] (e178216056.adsl.alicedsl.de [::ffff:85.178.216.56]) (AUTH: LOGIN jan, TLS: TLSv1/SSLv3,128bits,AES128-SHA) by jan.prima.de with esmtp; Wed, 22 Oct 2008 22:00:18 +0000 Message-Id: <1CB9380F-23FC-4BB6-91D8-B5314537927F@apache.org> From: Jan Lehnardt To: couchdb-user@incubator.apache.org In-Reply-To: <48FE021F.5010206@tangentlabs.co.uk> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v928.1) Subject: Re: 412 on update Date: Wed, 22 Oct 2008 23:59:46 +0200 References: <705343.14531.qm@web57207.mail.re3.yahoo.com> <48FE021F.5010206@tangentlabs.co.uk> X-Mailer: Apple Mail (2.928.1) X-Virus-Checked: Checked by ClamAV on apache.org On Oct 21, 2008, at 18:23 , Jonathan Moss wrote: > 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. and from Nick: > Why are you casting it from a string in the first place? Just treat > it as an > opaque value and return it to the server as sent to you. Besides, > you can't > represent every possible 64 bit integer in a double anyway. For a brief time, CouchDB's revision ids were integers. That is when CouchSimple was written and I was probably too lazy to keep the wiki updated. Sorry! :) Cheers Jan -- > > > 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 >