couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Anderson <>
Subject Re: Silent corruption of large numbers
Date Tue, 10 Nov 2009 07:54:44 GMT
On Mon, Nov 9, 2009 at 11:36 PM, Roger Binns <> wrote:
> Hash: SHA1
> Paul Davis wrote:
>> The only answer that sounds sensible to me is to code defensively and
>> make your own guarantees on data passing. The Couch world is only
>> going to expand, so data will come and go from a huge multitude of
>> sources and through any number of intermediaries.
> The last phrase is what scares me.  My component being defensive won't
> protect the ultimate end user from the other parts.

If your concern is this strong, then you should be encoding your
numbers as strings and writing your own number handling code.

Intermediaries are a fact of life on the web, and these days,
intermediaries might even be parsing and reencoding your JSON. CouchDB
goes above the JSON spec in many ways (object key ordering, native
number handling) but we can't, as a pragmatic matter, be responsible
for the behavior of JavaScript or other query-server engines.

If you need application level support for precise numbers, please roll
your own view server, or just rely on CouchDB documents (not the view
servers) to handle large numbers accurately.

I think it's fine that our JS engine is lossy on large numbers. If it
turns out to be trivial to patch for better math, I'd be in support.

Thanks again for the attention to detail. It's important that people
discuss the proper way to handle these cases.


Chris Anderson

View raw message