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

fix(mutator): match deep set/setIfMissing behavior #5048

Merged
merged 1 commit into from
Oct 27, 2023

Conversation

rexxars
Copy link
Member

@rexxars rexxars commented Oct 23, 2023

Description

There seems to be a few mismatches between @sanity/mutator and Content Lake:

  • In Content Lake, a set/setIfMissing-patch targeting a deep key with missing parents will recursively create an object structure for it
  • In @sanity/mutator, it will stop once it encounters a key that is not present in the document.

This PR attempts to align the behavior with what Content Lake does. Please review carefully - my knowledge of the mutator is limited and there may be (edge) cases I have not considered.

Fixes SDX-772.

Edit: I see that arrays also gets overwritten in a similar vein as primitives, but I am not quite sure yet how to resolve it.

What to review

  • Mutations work as expected

Notes for release

  • Fixed an issue where certain remote patches would not cleanly apply in the studio, requiring a reload of the document in order to see the change

@rexxars rexxars requested review from a team October 23, 2023 21:54
@vercel
Copy link

vercel bot commented Oct 23, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
performance-studio ✅ Ready (Inspect) Visit Preview Oct 23, 2023 9:54pm
test-studio ✅ Ready (Inspect) Visit Preview Oct 23, 2023 9:54pm
1 Ignored Deployment
Name Status Preview Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Oct 23, 2023 9:54pm

@github-actions
Copy link
Contributor

No changes to documentation

@github-actions
Copy link
Contributor

Component Testing Report Updated Oct 23, 2023 10:00 PM (UTC)

File Status Duration Passed Skipped Failed
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 8s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 9s 3 0 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 10s 6 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 28s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 13s 9 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 46s 18 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 10s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 6s 3 0 0

Copy link
Member

@bjoerge bjoerge left a comment

Choose a reason for hiding this comment

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

Wasn't aware of this behavior with nested set patches. Feels like it should trigger an error, but for now I agree it's more important to align with content lake behavior. Thanks!

@rexxars
Copy link
Member Author

rexxars commented Oct 24, 2023

Wasn't aware of this behavior with nested set patches. Feels like it should trigger an error, but for now I agree it's more important to align with content lake behavior. Thanks!

I agree, but I'd say it is unlikely to change in Content Lake given this behavior has always been this way, and maintaining backwards compatible patches is the priority for now.

@rexxars rexxars added this pull request to the merge queue Oct 27, 2023
Merged via the queue into next with commit 28884c6 Oct 27, 2023
18 checks passed
@rexxars rexxars deleted the fix/SDX-772-deep-set-setifmissing branch October 27, 2023 17:11
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