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

Gracefully handle create or update situations #21

Merged
merged 1 commit into from Jan 12, 2016

Conversation

Projects
None yet
2 participants
@burrows
Copy link
Member

burrows commented Jan 7, 2016

Several times now we've run into problems when we call save a NEW Transis model and the backend treats it as an update and returns the id of an existing record. If that id is already loaded into the Transis identity map, then an exception is raised. This PR handles that situation more gracefully by loading the response into the existing model instead of the NEW one.

This could still lead to some weirdness if you expect the NEW model to eventually reach the LOADED state but I feel that its better than just not handling this situation at all.

@burrows

This comment has been minimized.

Copy link
Member

burrows commented Jan 7, 2016

@peterwmwong @alexraginskiy Please take a look when you get a chance.

this.id = id;
}
else {
console.warn(`${this.constructor}#load: loading attributes that contain an id (${id}) that already exists in the identity map, the receiver will not be updated`);

This comment has been minimized.

@peterwmwong

peterwmwong Jan 8, 2016

Contributor

💰

burrows added a commit that referenced this pull request Jan 12, 2016

Merge pull request #21 from centro/handle-create-or-update
Gracefully handle create or update situations

@burrows burrows merged commit a1dd1c4 into master Jan 12, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment