couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jens Alfke <>
Subject Re: Is the revision field deterministic?
Date Tue, 08 Apr 2014 15:01:59 GMT

On Apr 8, 2014, at 7:31 AM, Daniel Gonzalez <> wrote:

> Ok, but does mean it is indeed related to the document content, so a
> different content would produce a different revision number.

Yes. It’s an MD5 (?) digest computed from the document JSON.

> And just curious: what does "the same content mean"? Is a different
> re-ordering of the json fields still passing the comparisson check?

I hope not[1], since the ordering of keys is undefined/insignificant in JSON and randomized
in many languages/libraries (ones that implement objects/dictionaries/maps using hash tables.)
In many languages simply reading JSON into memory and then serializing again can re-order
the keys. Even if it doesn’t (as in Erlang), it can change the escape sequences used in
strings, the number of decimal places used in non-integers, the presence of whitespace, etc.

Couchbase Lite computes rev IDs based on a canonical encoding[2] of the JSON that will always
generate the same result regardless of serialization differences. It won’t be the same result
arrived at by CouchDB, though.


[1]  I say “I hope not” because I don’t actually know the implementation of this in
View raw message