couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthew Sinclair-Day <msd...@gmail.com>
Subject Re: Integers changed to float in Couch 0.11.0
Date Fri, 02 Apr 2010 14:51:06 GMT
On 4/2/10 at 10:37 AM, paul.joseph.davis@gmail.com (Paul Davis) wrote:

>On Fri, Apr 2, 2010 at 10:29 AM, Matthew Sinclair-Day <msddsm@gmail.com> wrote:
>>On 4/2/10 at 1:31 AM, paul.joseph.davis@gmail.com (Paul Davis) wrote:
>>
>>> On Thu, Apr 1, 2010 at 8:15 PM, Matthew Sinclair-Day <msddsm@gmail.com>
>>> wrote:
>>>>
>>>> On 4/1/10 at 7:22 PM, jchris@gmail.com (J Chris Anderson) wrote:
>>>>
>>>>> On Apr 1, 2010, at 4:14 PM, Matthew Sinclair-Day wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I have upgraded to the 0.11 release and have noticed Couch is
>>>>>> changing integer values into floats. 1270162450695 became
>>>>>> 1270162450695.0.  This is a change from the 0.10.1 release.  Is
>>>>>> there a way to tell Couch not to do this?
>>>>>>
>>>>>
>>>>> You mean in the view engine. The document store will not effect data.
>>>>>
>>>>> The view engine is just JS, which has no distinction between integers
>>>>> and
>>>>> floats.
>>>>>
>>>>> I'm not sure why this would be different from the past.
>>>>>
>>>>> Chris
>>>>>
>>>>
>>>> I'm accessing the document directly by its ID, not by a view.  Does this
>>>> still go through the view engine?  I have confirmed the JSON going into
>>>> couch specifies an integer, and the JSON coming out of couch has it as a
>>>> float.
>>>>
>>>> Matt
>>>>
>>>>
>>>
>>> Can you provide a small script or shell session with curl that shows
>>> the problem?
>>>
>>> Paul
>>
>>Sure. Here's a curl session:
>>
>>curl -X POST http://localhost:5984/msdtest -d '{"num":123456789123456789}'
>>{"ok":true,"id":"8d211c89d80d14972af7cb93e71754bc","rev":"1-fce9e6cc4e72866f75aeadbaed1a65c9"}
>>
>>curl http://localhost:5984/msdtest/8d211c89d80d14972af7cb93e71754bc
>>
>{"_id":"8d211c89d80d14972af7cb93e71754bc","_rev":"1-fce9e6cc4e72866f75aeadbaed1a65c9","num":
>123456789123456780.0}
>>
>>In Futon, the 'num' value does not have a decimal.  I don't understand why
>>there would be a difference between the curl and Futon.
>>
>>It seems like the problem occurs with large numbers.  Here's another curl
>>where the num is not made into a decimal:
>>
>>curl -X POST http://localhost:5984/msdtest -d '{"num":123456789}'
>>{"ok":true,"id":"8d211c89d80d14972af7cb93e7175daf","rev":"1-039a59b36e40b4216eac91872eed4645"}
>>
>>curl http://localhost:5984/msdtest/8d211c89d80d14972af7cb93e7175daf
>>
>{"_id":"8d211c89d80d14972af7cb93e7175daf","_rev":"1-039a59b36e40b4216eac91872eed4645","num":
>123456789}
>>
>>Matt
>>
>>
>
>Well, there's a limit to what can be stored in an integer remember. I
>wouldn't really hold my breath for anything larger than 2147483648
>(2^31). The reason that Futon shows something different is because
>JavaScript treats all numbers as floats and then at display time it'll
>not display a fractional part if it's zero.
>
>I'm suprised that it used to work. Can anyone else on 0.10 verify
>that? I'm not sure if I remember anything changing in the number
>handling in mochijson or not.
>
>HTH,
>Paul Davis

Here's a session from 0.10.1 I just ran:

curl -X POST http://localhost:5984/msdtest -d '{"num":123456789123456789}'
{"ok":true,"id":"fcd6d8fca421023581a608758a0abe35","rev":"1-fce9e6cc4e72866f75aeadbaed1a65c9"}

curl http://localhost:5984/msdtest/fcd6d8fca421023581a608758a0abe35
{"_id":"fcd6d8fca421023581a608758a0abe35","_rev":"1-fce9e6cc4e72866f75aeadbaed1a65c9","num":123456789123456789}

At any rate, I will work around this on my end.

Matt


Mime
View raw message