Repository navigation
Conversation
RemoveOperation::_apply looped over every value to remove for each
existing value and appended the existing value once per non-matching
target. With two or more values to remove, matched values were kept and
unmatched values were duplicated, e.g. removing [1, 2] from [1, 2, 3]
returned [1, 2, 3, 3]. Removing an empty list also cleared the array.
The broken result is not only local: when a remove follows a set on the
same key, the operations merge into a SetOperation built from _apply, so
setArray('arr', [1, 2, 3]) followed by remove('arr', [1, 2]) saved
[1, 2, 3, 3] to the server.
Keep an existing value unless it matches any of the values to remove.
The match rules (strict equality, ParseObjects by objectId when not
dirty) are unchanged.
Add cases for RemoveOperation::_apply removing two or more values, removing every duplicate, removing nothing, and removing ParseObjects by objectId. Also check that merging with a previous SetOperation produces the correct value, since that value is sent to the server. These cases fail without the fix in RemoveOperation::_apply.
|
🚀 Thanks for opening this pull request! We appreciate your effort in improving the project. Please let us know once your pull request is ready for review. Tip
Note Please respond to review comments from AI agents just like you would to comments from a human reviewer. Let the reviewer resolve their own comments, unless they have reviewed and accepted your commit, or agreed with your explanation for why the feedback was incorrect. Caution Pull requests must be written using an AI agent with human supervision. Pull requests written entirely by a human will likely be rejected, because of lower code quality, higher review effort and the higher risk of introducing bugs. Please note that AI review comments on this pull request alone do not satisfy this requirement. Our CI and AI review are safeguards, not development tools. If many issues are flagged, rethink your development approach. Invest more effort in planning and design rather than using review cycles to fix low-quality code. |
New Pull Request Checklist
Issue Description
When
ParseObject::remove()is called with two or more values,RemoveOperation::_apply()returns the wrong array: values that should be removed are kept, and values that should be kept are duplicated.When
removefollowsseton the same key, the two operations are merged into a SetOperation whose value is the result of_apply(), so the broken value is saved to the server as is.Closes: N/A
Approach
The nested loop in
_apply()appended an existing value every time it did not match one of the values to remove.This PR changes it to drop an existing value if it matches any of the values to remove.
The check is done in a new private method,
isRemoved().===Added tests like
TODOs before merging
Summary by CodeRabbit