couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Anderson (JIRA)" <j...@apache.org>
Subject [jira] Commented: (COUCHDB-749) CouchDB does not persist large values of Numbers correctly.
Date Thu, 24 Jun 2010 18:08:53 GMT

    [ https://issues.apache.org/jira/browse/COUCHDB-749?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12882256#action_12882256
] 

Chris Anderson commented on COUCHDB-749:
----------------------------------------

I've patched mochijson2.erl again to give it the proper behavior. The patch is tiny. I'll
try sending it upstream and see what we get.


diff --git a/src/mochiweb/mochijson2.erl b/src/mochiweb/mochijson2.erl
index 66f68bf..111c37b 100644
--- a/src/mochiweb/mochijson2.erl
+++ b/src/mochiweb/mochijson2.erl
@@ -98,11 +98,8 @@ json_encode(false, _State) ->
     <<"false">>;
 json_encode(null, _State) ->
     <<"null">>;
-json_encode(I, _State) when is_integer(I) andalso I >= -2147483648 andalso I =< 2147483647
->
-    %% Anything outside of 32-bit integers should be encoded as a float
-    integer_to_list(I);
 json_encode(I, _State) when is_integer(I) ->
-    mochinum:digits(float(I));
+    integer_to_list(I);
 json_encode(F, _State) when is_float(F) ->
     mochinum:digits(F);
 json_encode(S, State) when is_binary(S); is_atom(S) ->


> CouchDB does not persist large values of Numbers correctly.
> -----------------------------------------------------------
>
>                 Key: COUCHDB-749
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-749
>             Project: CouchDB
>          Issue Type: Bug
>    Affects Versions: 0.11
>         Environment: All
>            Reporter: Jarrod Roberson
>
> All the following operations exhibit the same bug, large numbers don't get persisted
correctly. They get something added to them for some reason.
> 9223372036854775807 == java.lang.Long.MAX_VALUE
> 1: go into Futon, create a new document and create a new field and enter the number 9223372036854775807,
click the green check mark, the number changes to 9223372036854776000 even before you save
it.
> 2.curl -X PUT http://localhost:5984/test/longTest -d '{"value": 9223372036854775807}',
the number gets persisted as 9223372036854776000
> trying to persist System.currentTimeMilliseconds() from java causes the same thing to
happen occasionally.
> This seems to be a pretty serious bug if I can't trust that my data is not being corrupted
when submitted to the database.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message