daleharvey/pouchdb — pull request #403 by nick-thompson (2013-02-07 17:51:42+00:00)
Title: LevelDB adapter api.changes bug

[https://github.com/daleharvey/pouchdb/blob/master/src/adapters/pouch.leveldb.js#L698](https://github.com/daleharvey/pouchdb/blob/master/src/adapters/pouch.leveldb.js#L698)

```javascript
if (!opts.seq) {
opts.seq = opts.descending ? update_seq : '0';
}
if (opts.since) {
opts.seq = String(opts.since + 1);
}
```

This set of if clauses breaks the case where `opts.seq` is not defined, but `opts.since` and `opts.descending` are both defined. Specifically, if `opts.descending = true` and `opts.since = 0` (which happens in one of our test cases), then `opts.seq` becomes `'1'` when it should be `update_seq`.

Proposed fix:

```javascript
if (!opts.seq) {
opts.seq = opts.descending
? update_seq
: opts.since
? String(opts.since + 1)
: '0';
}
```

Thoughts? Maybe I'm missing some key piece of information?