std.mergePatch should create resulting object fields at Normal visibility, not Unhide#255
Merged
stephenamar-db merged 2 commits intodatabricks:masterfrom Jan 3, 2025
Conversation
e54095c to
9b40266
Compare
stephenamar-db
approved these changes
Jan 3, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR changes the default visibility of fields in objects created by
std.mergePatch: previously they were atUnhidevisibility, equivalent to the:::operator, but as of this PR they are now atNormalstandard visibility.Concretely, previously
would return
{a: 1}but after this patch it returns{a:: 1), i.e. it preserves the hidden field.It turns out that v0.20.0 of google/jsonnet and google/go-jsonnet also differ in their behavior here. That, in turn, is due to a behavior difference in the default visibility of fields in object comprehension results: jsonnet marks object comprehension fields as forced-visible, while go-jsonnet marks them as inherited visibility; see google/jsonnet#1111.
jsonnet accepted google/jsonnet#1140 to match go-jsonnet's behavior.
Note that sjsonnet already matches go-jsonnet's behavior for object comprehensions: we only have a difference in
std.mergePatchbecause our current implementation explicitly hardcodes Unhide visibility.This PR changes that mergePatch-specific behavior to match the current go-jsonnet (and future jsonnet) behavior.