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

Fixed falsey/null value issues in jsong merge #124

Merged

Conversation

sdesai
Copy link
Contributor

@sdesai sdesai commented Aug 25, 2015

@michaelbpaulson

This fixes the falsey issues similar to the ones mentioned in Netflix/falcor#460 and #120 but this time for JSONG (issues in jsongMerge this time, last time it was in optimizePathSet).

@@ -65,7 +66,7 @@ function merge(config, cache, message, depth, path, fromParent, fromKey) {
var values = config.values;
values.push({
path: cloneArray(requestedPath),
value: message.type ? message.value : message
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@michaelbpaulson, @jhusain

The message.type here seems to be a bug also, but 'fixing' it (I assume it's supposed to be message.$type as opposed to message.type) breaks the JSONG - Merge should write a simple path to the cache basic unit test in jsongMerge.spec.js. Needed some input on what the expected output should be for this test to determine if the test is broken, or there are potentially more bugs in the jsongMerge impl, which need to be teased out.

This is the failing test, if I change this line to be message.$type:

1) Router Unit Internals JSONG - Merge should write a simple path to the cache.:

      AssertionError: expected { Object (references, values) } to deeply equal { Object (values, references) }
      + expected - actual

             "path": [
               "there"
               "is"
             ]
      -      "value": "a value"
      +      "value": {
      +        "$type": "atom"
      +        "value": "a value"
      +      }
           }
         ]
       }

Copy link
Contributor

Choose a reason for hiding this comment

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

@sdesai you are correct. I think the good news is that we remove that statement and only ever use the value that is handed to us. This could potentially strip some valuable meta data on a node by using the .value of the handed back value.

So what I am saying is that you were correct in assuming that this is incorrect, because it is. But the fix is to remove message.type ? message.value : message with message

@ThePrimeagen
Copy link
Contributor

This is good to me.

ThePrimeagen added a commit that referenced this pull request Aug 25, 2015
Fixed falsey/null value issues in jsong merge
@ThePrimeagen ThePrimeagen merged commit 3b3a6a8 into Netflix:master Aug 25, 2015
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.

2 participants