Fix dirty attribute changes on update#1149
Merged
nelsonwittwer merged 7 commits intomainfrom May 2, 2023
Merged
Conversation
AnthonyRobertson17
added a commit
that referenced
this pull request
May 10, 2023
5 tasks
AnthonyRobertson17
added a commit
that referenced
this pull request
May 17, 2023
5 tasks
AnthonyRobertson17
added a commit
that referenced
this pull request
May 18, 2023
AnthonyRobertson17
added a commit
that referenced
this pull request
May 18, 2023
| T.unsafe(@has_one[attr_sym]).create_instance(data: data_hash, session: session)) | ||
| child = T.unsafe(@has_one[attr_sym]).create_instance(data: data_hash, session: session) | ||
| instance.public_send("#{attribute}=", child) | ||
| instance.original_state[attr_sym] = child.to_hash(true) |
There was a problem hiding this comment.
This was a breaking change for our application that went unreported in the changelog. We were creating an instance and immediately calling save on it, which with this change resulted in an empty hash being sent to Shopify (since the original state matched the current state after instantiation)
I.E. ShopifyAPI::ObjectName.build(attrs).save! <- this fails now AFAICT
There was a problem hiding this comment.
Not sure if we were using the library improperly since I didn't see mention of this is the docs, but if not I can go update the changelog for others who might run into this. cc @nelsonwittwer
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.
Description
Fixes #1133 and #1037 which both report a substantial issue with tracking what attributes were actually modified by the user since the rest resources were initialized.
The root cause of this issue, as pointed out by @kaarelss, was symbols vs hashes when comparing drift on attributes 🤦 . I also needed to 1) set associations in
original_statesince our API allows us to modify associated resources and 2) needed to ignore read only attributes inoriginal_state.How has this been tested?
Checklist: