Skip to content
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

Fixes errorSelector bugs. #611

Merged
merged 7 commits into from
Dec 10, 2015
Merged

Fixes errorSelector bugs. #611

merged 7 commits into from
Dec 10, 2015

Conversation

sdesai
Copy link
Contributor

@sdesai sdesai commented Nov 9, 2015

a. errorSelector was not being invoked for branches/replaced nodes
during merges. It was only invoked on new leaf insertion.

b. errorSelector was being called with truncated paths. This impacted
both sets, and merges from the datasource response.

NOTE. This should not be merged yet. Unit tests coming. Wanted to get some eyes on the fix.

@michaelbpaulson

a. errorSelector was not being invoked for branches/replaced nodes
   during merges. It was only invoked on new leaf insertion.

b. errorSelector was being called with truncated paths. This impacted
   both sets, and merges from the datasourc response.

Unit tests coming.
module.exports = function reconstructPath(currentPath, key) {

// The first time called during a walk, currentPath.index won't be set.
var currentPathIndex = (currentPath.index || 0) + 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only thing I don't like about this, and we will have to change it at some point, is that set relies an mutating the input with index. We can rely on this for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. I'm happy to feed in index, but it seems like those are heavily coupled already (requestedPath and requestedPath.index always have to by in sync don't they?), so separating them here seems riskier, unless we separate them all the way up.

@trxcllnt
Copy link
Contributor

trxcllnt commented Nov 9, 2015

They can be separated, but yes they're always updated in lock-step. Index was added after the recursive function signatures were defined (I didn't realize we needed it till later in the game), so it was purely a cosmetic choice not to go back and update all the signatures (and call-sites) with index params.

@sdesai
Copy link
Contributor Author

sdesai commented Nov 9, 2015

Makes sense. Planning to leave them alone for the purposes of this fix/change to get errorSelector working properly. Can treat as a cleanup task.

Otherwise we'd get the wrong errorPath for [foo, [baz, fizz], bar] and
similar iterated key sets of size > 1.
@sdesai
Copy link
Contributor Author

sdesai commented Nov 10, 2015

Needed to take another stab at it, since due to the nature of the do/while loop, index wasn't enough info to reconstruct the errorPaths fed to the selector for PathSets with keySets of size > 1, e.g. [foo, bar, [baz, fizz]] or [foo, [baz, fizz], bar]. I needed to add a depth which would stay the same when processing both the baz, and fizz keys. Chose to add it to the requestedPath "object" (even though it was fairly trivial to add it as an extra arg, since that's effectively the datastructure we're using to carry around the requestedPath related state through the recursion and related method calls and needs to stay in sync.

Again, eyeballs appreciated.

@sdesai
Copy link
Contributor Author

sdesai commented Dec 10, 2015

@michaelbpaulson - Gonna merge this in, unless you you want to take a look at it?

@ThePrimeagen
Copy link
Contributor

ThePrimeagen commented Dec 10, 2015 via email

sdesai added a commit that referenced this pull request Dec 10, 2015
@sdesai sdesai merged commit d172359 into 0.x Dec 10, 2015
@ThePrimeagen ThePrimeagen deleted the errorSelectorFixes branch January 29, 2016 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants