Skip to content
This repository has been archived by the owner on Dec 6, 2018. It is now read-only.

keyStream, readStream, valueStream disappear on sublevel #84

Closed
dweinstein opened this issue Jan 25, 2015 · 4 comments · Fixed by #86
Closed

keyStream, readStream, valueStream disappear on sublevel #84

dweinstein opened this issue Jan 25, 2015 · 4 comments · Fixed by #86

Comments

@dweinstein
Copy link
Contributor

the prototype keyStream seems to be lost on the sublevel which may cause incompatibilities for code that expects it to be present, for example level-delete-range

@dweinstein
Copy link
Contributor Author

I found Level/levelup#53 and see that maybe keyStream is just going away. I'll fork level-delete-range maybe and just have it switch over to createReadStream for good.

@dweinstein
Copy link
Contributor Author

Here's my test case:

var tap = require('tap');
var test = tap.test;

var db = require('level')('foo');
var sub = require('level-sublevel')(db);

test('db and sub db test', function (t) {

  test('test without sublevel', function (t) {
    t.type(db.createReadStream, 'function');
    t.type(db.keyStream, 'function');
    t.end();
  });

  test('test with sublevel', function (t) {
    t.type(sub.createReadStream, 'function');
    t.type(sub.keyStream, 'function');
    t.end();
  });

  t.end();
});

Result

TAP version 13
# db and sub db test
# test without sublevel
ok 1 type is function
ok 2 type is function
# test with sublevel
ok 3 type is function
not ok 4 type is function
  ---
    file:   /Users/user/git/dweinstein/test/test.js
    line:   18
    column: 7
    stack:
      - |
        getCaller (/Users/user/node_modules/tap/lib/tap-assert.js:418:17)
      - |
        assert (/Users/user/node_modules/tap/lib/tap-assert.js:21:16)
      - |
        Function.equal (/Users/user/node_modules/tap/lib/tap-assert.js:162:10)
      - |
        Function.type (/Users/user/node_modules/tap/lib/tap-assert.js:320:17)
      - |
        Test._testAssert [as type] (/Users/user/node_modules/tap/lib/tap-test.js:87:16)
      - |
        Test.<anonymous> (/Users/user/git/dweinstein/test/test.js:18:7)
      - |
        Test.emit (events.js:117:20)
      - |
        Test.emit (/Users/user/node_modules/tap/lib/tap-test.js:104:8)
      - |
        GlobalHarness.Harness.process (/Users/user/node_modules/tap/lib/tap-harness.js:87:13)
      - |
        process._tickCallback (node.js:442:13)
    found:  undefined
    wanted: function
    diff:   |
      FOUND:  undefined
      WANTED: function
              ^ (at position = 0)
  ...

1..4
# tests 4
# pass  3
# fail  1

@dominictarr
Copy link
Owner

can you make a pull request for this? Testing that a function exists means nearly nothing - check that it's a function that returns a stream that does the same thing as passing in {keys: true}. That, or make a pull request to level-delete-range that just uses createReadStream.

Probably we should consider keyStream a legacy api, but it probably won't be going anywhere... note that issue is from 2013!

dweinstein added a commit to dweinstein/level-sublevel that referenced this issue Jan 28, 2015
@dweinstein
Copy link
Contributor Author

the size of the test felt a little silly because the methods are just aliases and the fix is so trivial, but hopefully it'll prevent some other strange issue in the future

@dweinstein dweinstein changed the title keyStream disappears on sublevel keyStream, readStream, valueStream disappear on sublevel Jan 28, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants