pouchdb/pouchdb — pull request #3308 by willholley (2014-12-30 14:29:02+00:00)
Title: (#136) - Fix "Test pull replication with many changes"

CouchDB 2.0 represents sequence numbers as arrays which should be treated as opaque blobs. This prevents us using simple comparison operators on them (e.g. last_seq < current_seq).

Previously we were using a similar test to determine whether new changes were returned in a call to _changes (if params.since < result.last_seq, fetch more changes). This no longer holds so, instead, fetch more changes if the last_seq returned is not equal to the since
parameter (if params.since != result.last_seq, fetch more changes).

There is a danger here of a loop because there is no guarantee that last_seq will be consistent between successive calls to _changes in a clustered CouchDB (rare that this happens but it's possible). I considered a break clause based on the number of documents returned by _changes but filtered replication would scupper that I think. Suggestions for a better solution are welcome ;)