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(sdk): improve delete() method for MutJson class #6278

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

partha04patel
Copy link
Contributor

@partha04patel partha04patel commented Apr 19, 2024

Checklist

  • Title matches Winglang's style guide
  • Description explains motivation and solution
  • Tests added (always)
  • Docs updated (only required for features)
  • Added pr/e2e-full label if this feature requires end-to-end testing

By submitting this pull request, I confirm that my contribution is made under the terms of the Wing Cloud Contribution License.

@partha04patel partha04patel requested a review from a team as a code owner April 19, 2024 22:54
@partha04patel partha04patel marked this pull request as draft April 19, 2024 22:54
Copy link

github-actions bot commented Apr 19, 2024

Thanks for opening this pull request! 🎉
Please consult the contributing guidelines for details on how to contribute to this project.
If you need any assistence, don't hesitate to ping the relevant owner over Discord.

Topic Owner
Wing SDK and utility APIs @chriscbr
Wing Console @ainvoner, @skyrpex, @polamoros
JSON, structs, primitives and collections @hasanaburayyan
Platforms and plugins @hasanaburayyan
Frontend resources (website, react, etc) @tsuf239
Language design @chriscbr
VSCode extension and language server @markmcculloh
Compiler architecture, inflights, lifting @yoav-steinberg
Wing Testing Framework @tsuf239
Wing CLI @markmcculloh
Build system, dev environment, releases @markmcculloh
Library Ecosystem @chriscbr
Documentation @hasanaburayyan
SDK test suite @tsuf239
Examples @hasanaburayyan
Wing Playground @eladcon

@partha04patel
Copy link
Contributor Author

Intended for having delete() work for non-map MutJson instances as brought up by @Chriscbr and @MarkMcCulloh from #6236

monadabot and others added 2 commits April 19, 2024 19:10
Signed-off-by: monada-bot[bot] <monabot@monada.co>
@monadabot monadabot added the ⚠️ pr/review-mutation PR has been mutated and will not auto-merge. Clear this label if the changes look good! label Apr 19, 2024
@partha04patel partha04patel marked this pull request as ready for review April 20, 2024 15:47

The key.
Either the key or index to delete.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Im not sure we should allow deletion at an index. While it may seem like order is preserved in most JSON objects, this is not a guarantee, according to the json specification "An object is an unordered set of name/value pairs"

Copy link
Collaborator

Choose a reason for hiding this comment

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

It makes sense for Json Arrays, since their order is preserved but perhaps in these cases its better to just convert types

"key5": [3, 2, 1]
}
});
assert(original.delete("key5")==true);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This returning true feels off. Since "key5" is not a top level key of original it should be original["object"].delete("key5")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can see why it feels off, technically the returning true makes sense since "key5" was never present as a top level key of original, but original["object"].delete("key5") should also return true as well with it actually deleting the present key

@revitalbarletz
Copy link
Collaborator

@partha04patel do you need any additional help here? seems like we are almost done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚠️ pr/review-mutation PR has been mutated and will not auto-merge. Clear this label if the changes look good!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants