cbforest icon indicating copy to clipboard operation
cbforest copied to clipboard

InclusiveEnd=false query does not work unless end key is specified

Open borrrden opened this issue 9 years ago • 3 comments

ForestDB disallows skipping keys if the keys are empty, which means that when CBForest uses an empty Collatable then any query with InclusiveEnd=false (or descending and InclusiveStart=false) will fail because the enumerator will be NULL due to an error unless the end (or start in the case of descending) key is specified.

WARNING: ForestDB error: invalid arguments (-1)

borrrden avatar Sep 28 '16 23:09 borrrden

I just ran into this a few days ago. It's worth looking at what CouchDB does in this situation; it might just ignore the inclusiveEnd flag if there's no endKey.

snej avatar Sep 29 '16 03:09 snej

Confirmed that is the behavior on 1.6.1. Without endkey specified all rows are returned in spite of inclusive_end. Furthermore, there is no inclusive_start parameter.

borrrden avatar Sep 29 '16 06:09 borrrden

Good! I had a feeling it would do that, because the alternative is annoying to implement — you have to stay one iteration ahead of what you return, so you can throw away the last row when you hit the end.

So the fix is to simply set the inclusive___ flag if the corresponding ___key parameter is null.

snej avatar Sep 29 '16 16:09 snej