-
Notifications
You must be signed in to change notification settings - Fork 450
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
stdlib: implement json merge #95
Conversation
Try this on for size:
|
Also, the reason you have some failing test cases is because you've changed std.jsonnet and the line numbers in the "golden" stacktraces for unrelated tests no-longer align. To fix that, use refresh_golden.sh to rewrite the "golden" files with the new content (and sanity check with git diff). |
Maybe this should be called mergePatch, and it really calls out for the diff equivalent as well, although not necessarily in this PR. |
It looks like 7396 is the better RFC as it obsoletes 7386 |
It looks like the pseudocode algorithm for applying a patch did not change between the three RFC revisions so the difference must be in the http parts. Nice! this seems to work:
It fixes all extra nulls except for the one in the last test case. |
I think it will work with this as the inner block:
|
I think that is equivalent since std.merge(null, patch[k]) evaluates to patch[k](always hits the else). The problem is with the else return patch branch. To conform to the spec we would have to walk the patch object and strip out all explictly null fields. |
Nah std.merge(null, patch[k]) is recursive into patch[k] std.merge(x, null) evaluates to null though |
Ok I gotcha. I've updated the patch. |
Looks like error.equality_function.jsonnet.golden needs updating |
47c580b
to
81642a8
Compare
@@ -0,0 +1 @@ | |||
true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Absence of a .golden file means it should expect it to output just true, so you can delete this file.
Adds a merge function to the stdlib as described in: https://tools.ietf.org/html/rfc7396 https://tools.ietf.org/html/rfc7386 https://tools.ietf.org/html/draft-ietf-appsawg-json-merge-patch-07 Signed-off-by: Mike Danese <[email protected]>
@sparkprime addressed comments and build is all green |
stdlib: implement json merge
Adds a merge function to the stdlib as described in:
https://tools.ietf.org/html/rfc7386
https://tools.ietf.org/html/draft-ietf-appsawg-json-merge-patch-07
There's some wierdness around patching nulls. I couldn't figure out how to remove a node from the json object so some of the test cases have an extra null in the expected output which seems okay. I've left a comment where are expected differs from the spec's expected differs from our expected.