Nick Johnson wrote:
I wasn't my code doing the casting. I am using the CouchDB PHP classes from the couchprojects php library. It is that code which is casting to float. I am quite happy to modify the code but it would be nice to be able to commit my changes upstream so that other can benefit from them. Anyone have any idea who I can ask to get write privileges to the svn repo or who I can send the changes to?On Tue, Oct 21, 2008 at 5:23 PM, Jonathan Moss < [EMAIL PROTECTED]> 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.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.
Regards, Jon I believe a 412 is a conflict, anyone care to prove me wrong?----- Original Message ---- From: Jonathan Moss <[EMAIL PROTECTED]> To: couchdb-user@incubator.apache.org Sent: Tuesday, October 21, 2008 3:07:43 AM Subject: Re: 412 on updateHi 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, JonI 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
smime.p7s
Description: S/MIME Cryptographic Signature