couchbaselabs/TouchDB-iOS — Issue #10: Conflict "winner" rule is slightly wrong
Author: snej
Created: 2011-12-19 21:57:00+00:00
State: open
Labels: bug

When there are conflicting revisions, the database has to pick one as the 'winner' to return to an ordinary GET, until the client resolves the conflict. I thought the algorithm was simply to compare the revision IDs (as binary) and pick the highest one.

I just found out from Damien that the actual algorithm CouchDB uses is to pick the revision that's deepest in the tree, i.e. the one whose numeric prefix is greatest. Only if there's a tie is the opaque part of the revision ID compared.

This is pretty close to what I have, in fact by accident TouchDB will get the right result until the revision count goes past 9, but it should be fixed.