-
-
Notifications
You must be signed in to change notification settings - Fork 266
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
json valueEncoding doesn't work as expected #495
Comments
Thanks for reporting this. We are aware of it. But nice to have a separate issue for it :) |
Will fix this today or tomorrow. After that I think we should release 2.0.0. |
Great to hear that, awesome! |
Looking forward to the release 2.0.0... It seems that my build will not succeed until v2.0.0 is published... > flash-store@0.0.14 dist:es6to5 /home/zixia/git/flash-store
> tsc --out ./bundles/flash-store.umd.js --target es5 --allowJs bundles/flash-store.es6.umd.js --lib es6,dom
node_modules/levelup/lib/levelup.d.ts(113,16): error TS2694: Namespace '"/home/zixia/git/flash-store/node_modules/abstract-leveldown/index"' has no exported member 'LevelDOWN'.
node_modules/levelup/lib/levelup.d.ts(127,16): error TS2694: Namespace '"/home/zixia/git/flash-store/node_modules/abstract-leveldown/index"' has no exported member 'LevelDOWN'. My current dependence version: "encoding-down": "^2.3.1",
"leveldown": "^2.0.0",
"levelup": "^2.0.0-rc3", |
@zixia Mind trying this out again? |
It seems still have problems. I'm using the following dependences: "encoding-down": "^2.3.1",
"leveldown": "^2.0.0",
"levelup": "MeirionHughes/levelup", After import encoding from 'encoding-down'
import leveldown from 'leveldown'
import levelup from 'levelup'
async function main() {
const encoded = encoding(leveldown('/tmp/test'), {
valueEncoding: 'json',
})
const levelDb = levelup(encoded)
await levelDb.put('test', {a: 1})
const value = await levelDb.get('test')
console.log('value type:', typeof value) // value type: string
console.log('value:', value) // value: [object Object]
}
main() Output: $ ts-node t.ts
value type: string
value: [object Object] The value type should be 'object' |
@zixia I ran your example in node (with levelup
|
Cannot reproduce with TS either. Seems to work fine here, and fails as expected if I downgrade |
@vweevers I had tried again, but I still ran into the same buggy result. I had pushed my configuration & source code at here: huan/flash-store@abfb02b Travis CI result(failed) at here: https://travis-ci.org/zixia/flash-store/jobs/284564104#L762 operator: equal
expected: 'object'
actual: 'string'
at: Object.<anonymous> (/home/travis/build/zixia/flash-store/src/flash-store.spec.ts:154:5) |
@zixia from the travis logs, seems it didn't install the latest
|
@vweevers Yes, you are right. After installing the deferred-leveldown@2.0.2, the test passed! # levelup json bug
ok 19 value type should be object
ok 20 should get back the original object Sorry for misreporting because I was thought the leveldown had already linked the latest version of it. |
I'm not sure how the latest npm dedupes, we might need to depend on |
@vweevers It can't hurt :) |
if @zixia is using yarn or npm 5, there will be a lockfile; I imagine it won't bump up versions unless you explicitly do so, or something depends on a specific patch version minimum. |
right. damn lockfiles :) |
Maybe we should add tests for this. |
To levelup you mean? +1 |
Yes |
There might have other problems with the version dependencies because I'm not using +1 for unit test, and I'd like to suggest that we also add a TypeScript unit test in |
😁
Broken in what way? |
It's just my 2 cents. I think if we could have a repository that integrated with all the level-* modules and have a build/test script automatically run by CI, after enabled greenkeeper auto update, it might be able to help us to monitor the comparable status of every module update on NPM. :) |
Tests for this added in #508 |
I use json valueEncoding for v1 and it works without any problem.
After upgrade to v2, It does not work anymore: after putting an object to leveldb, we will get back a
[object Object]
value ofstring
type.The following code can be able to reproduce the problem:
After a little digging, I found the following code in AbstractLevelDOWN, which is just
String(value)
for the value.I have no idea how to fix it because there's too many modules/layers.
The text was updated successfully, but these errors were encountered: