-
-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix iterating buffer keys that contain bytes 196-255 #88
Conversation
if (Buffer.isBuffer(x) && !x.length) x = END | ||
return concat(self.prefix, x || '\xff') | ||
if (!x || isEmptyBuffer(x)) { | ||
return self.prefix.slice(0, -1) + ceiling |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An example: if the separator is !
then the "ceiling" is "
. If you have a bunch of sublevels with prefixes ['!a!', '!a!!a!', '!aa!', '!b!']
and you want to get everything in !a!
, then that's everything less than !a"
.
$ node
> ['!a!', '!a!!a!', '!aa!', '!b!', '!a"'].sort()
[ '!a!', '!a!!a!', '!a"', '!aa!', '!b!' ]
Is there a case where this doesn't work? Apart from a custom separator
that leaves no room for the ceiling, like sub(db, '0', { separator: '/' })
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a really good idea also for defining keys in general cases and get a range of it.
Previously (in any version) such keys were wrongly excluded by the range logic of subleveldown. The fix is not breaking for most folks. It's breaking if you: - Use the default separator and prefixes that contain '"' (byte 34) - Use a custom separator that doesn't sort 2 positions before characters used in your prefixes. For example with separator '/' (byte 47) prefixes must use characters greater than '0' (byte 48). In either case, an error will be thrown from the constructor.
123148e
to
dd82d61
Compare
5.0.0 |
Closes #87. Previously (in any version) keys containing bytes 196-255 were wrongly excluded by the range logic of
subleveldown
. The fix is not breaking for most folks.It's breaking if you:
"
(byte 34)/
(byte 47) prefixes must use characters greater than0
(byte 48).In either case, an error will be thrown from the constructor.