-
Notifications
You must be signed in to change notification settings - Fork 324
Unable to nullify string attribute using the update function... #104
Comments
I can confirm that when I remove the |
Update: As a work around I used the custom data structure workflow to create a variant that didn't have the |
@ckeyes88 thanks for the comments and sorry for the trouble. I haven't been using this feature for a while, but according to the documentation, it sounds like the
As such, I would be hesitant to remove the |
@dlebech Thanks for the response! I agree that it should not be set to Interested to hear your thoughts. |
@ckeyes88 I see your point. When inventory management is initially unset, it will remain unset forever because of the If we removed Because of the support for partial updates, it feels like Would love to hear what others have to say about this. I think it's a bit of a conundrum, even though it seems very simple :) |
Ya the more I thought about it the more I realized it wasn't as simple as changing the How to determine if a JSON key has been set to null or not provided I suspect this is why, for example the AWS Golang sdk implements their own primitive datatypes Thanks again for your feedback/thoughts. |
Just adding some more reference information from an issue on the Go-Github sdk discussing the exact same problem and potential solutions. |
@ckeyes88 thanks for the links. This is perhaps an issue that can be tackled as part of some larger updates of the library since it also might require a breaking change. |
This issue was moved to bold-commerce#4 |
Currently, string values on any of the data structs have the
omitempty
tag associated with them. Because of this, if I try to set a string value to it'snil
value""
,json.Unmarshal
andjson.Marshal
leave off that attribute. This is a problem when trying to update a string field that I want to unset.Steps to reproduce (using a variant as example):
v.InventoryManagement = "shopify"
v.InventoryManagement = ""
shopify.Variant.Updated(v)
Expected: The returned updated variant should have
v.InventoryManagement == ""
and that variant should no longer be set to have shopify track inventory.Actual: The returned updated variant has
v.InventoryManagement == "shopify"
and that variant has no changes to it's inventory management in the admin console.Proposed fix: Convert the string values to string pointers so that they can be explicitly nil-able.
If I'm thinking about the problem incorrectly, I'd love some feedback on how to unset string properties.
The text was updated successfully, but these errors were encountered: