Do not wrap array attributes in a new array on User.merge - #755
Open
jnbdz wants to merge 1 commit into
Open
Conversation
When merging two users where only the other user has an array attribute for a given key, the attribute ended up as an array nested inside a new array, e.g. roles ["write"] became [["write"]]. Keep a copy of the other user array instead, consistent with how the remaining accumulate cases behave. Fixes eclipse-vertx#550
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.
When merging two
Userobjects where only the merged-in user has an array attribute for a given key,User.mergewrapped that array in a new array:roles = ["write"]becameroles = [["write"]].The accumulate logic in
UserImpl.mergehandled every combination correctly (array+array concatenates, scalar+scalar becomes a two-element array, ...) except the case where the current user has no value for the key and the other user's value is an array — that branch added the whole array as a single element. This change keeps a copy of the other user's array instead, consistent with the copy the method already makes when the whole attributes object is absent.Added coverage to
UserTestfor array attributes present on only one side of the merge (both directions).Fixes #550