Conversation
In two situations: - When reopening a nested sublevel, because on open we add the parent's prefix to the child's prefix. Open twice, and you get a double prefix. Fixed by keeping around the original prefix. - When having more than 2 nested sublevels. This resulted in subdown wrapping subdown, effectively applying a double prefix to keys. Fixed by tweaking the unwrapping voodoo.
| self.prefix = subdb.prefix + self.prefix | ||
| self.leveldown = reachdown(subdb.db, matchdown, false) | ||
| self.prefix = subdb.prefix + self.ownPrefix | ||
| self.leveldown = subdb.leveldown || reachdown(subdb.db, matchdown, false) |
There was a problem hiding this comment.
We should only need 1 one of these solutions (either subdb.leveldown or reachdown(..)), not sure which I like best.
There was a problem hiding this comment.
Gonna go with subdb.leveldown because reachdown(sub.db) is like taking a detour (it goes: own levelup -> encoding-down -> subleveldown -> external levelup -> encoding-down -> leveldown).
|
I've approved solely on the basis you've added a unit test for the case - I'm afraid I don't know the ramifications of the choice you outlined above; the best I can suggest/ask is whether one approach is better at handling "exotic" subdowns. i.e. |
|
@MeirionHughes Roger, thanks. We support those exotic situations since 4.1.3 and have a test for it :) |
In two situations:
Closes #78. This PR is an alternative to #79, which fixes more issues but is WIP, more invasive and semver-major, while this is semver-patch (with a caveat).