-
-
Notifications
You must be signed in to change notification settings - Fork 53
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
Remove stringification of keys and values #85
Conversation
levelup handles this already, and if the user passes encoding:'id' they should know what they're doing and the backend will get the chance of storing the value natively without always having to deal with just a buffer or a string
I never leave a drive-by 👍, but @juliangruber asked for 'em, so: +1 from me! |
thanks @joeybaker ❤️ |
+1 |
Huge 👍 |
How could we best communicate this change to downstream users? It's a pretty big one and could open up some problems that won't necessarily be picked up by test suites. |
or function DB(){
AbstractLevelDOWN.call(this, name, {
toBuffer: false
})
} |
That'd actually be a great first step regardless, make it opt-in for now, switch to opt-out and maybe remove in the future. |
check this out |
LGTM 👍 But why not An alternative (perhaps a bit more flexible) design just came to mind: add a AbstractLevelDOWN.prototype._serialize = function (input) {
return this._isBuffer(input)) ? input : String(input)
} Then on Does this sound reasonable? |
this sounds mega perfect! i've thought about this for a little and it so makes sense. i'll work on it |
actually, it needs to be slightly more complicated, because serialization depends on whether it's a key or a value. i'll create |
ok how does this look? |
@juliangruber: that's beautiful, man! 👍 |
added a couple missing tests and fixed the bug magnus discovered. mergeable as a minor? |
+1 |
thanks @ralphtheninja and @deanlandolt! @rvagg can i get a +1 from you as well? |
👍 |
Remove stringification of keys and values
2.5.0 it is! |
So it looks like this was indeed a breaking change, because AFAICT from git-bisecting, this commit broke memdown: Level/memdown#55 |
BTW maybe we should start using something like dont-break in this project, because I feel like we run into the situation a lot where somebody merges something and then it randomly breaks FooDOWN somewhere in the ecosystem. |
+1 |
you're right that this actually is a breaking change. Before, I'm working on a pull request to revert this breaking change. |
Fixed in 7f514f4, committed straight to master and released as 2.6.1. The memdown test suite passes with this version :) |
Awesome, thank you!! :) So just to check - this changes the on-disk representation of data? I.e. if I created data with <2.5.0, if I then open it in 2.6.0 the data may be changed/corrupted? |
it changes how data nullish values are stored in 2.6.0., 2.6.1 however will behave the same as 2.5.0 |
Commented on this in Level/memdown#57 (comment), but there's something basic I'm not understanding: if I write data in 2.4.1, then read that same data in 2.6.1, is the data changed/corrupted? If so, then 2.5.0 should have been a major version bump, and in addition it would need to offer some guidelines on how to migrate userdata over (or determine if a migration is necessary). Yes this only applies to nullish data, and yes memdown isn't affected, but this project has a lot of dependents so it's worth communicating downstream if package authors need to figure out a migration path. |
only 2.6.0 is the faulty version. 2.6.1 and 2.5.0 have (or should have) full compatibility with anything done with 2.4.1. |
OK, I misunderstood. Thanks for clarifying! |
levelup handles massaging keys and values through its encoding layer already. However, if the user passed
encoding: 'id'
, abstract-leveldown would still convert everything to a string or buffer. For those encodings, like level.js and postgres-down that do support more of the native JS values, this gives them the chance of receiving the raw values and encoding them themselves.It's a breaking change and so if merged will need a
3.0.0
release.