Skip to content

fix(RelationshipAttribute): correct Equals and ToString #73

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

Merged
merged 2 commits into from
Mar 23, 2017

Conversation

jfhs
Copy link
Contributor

@jfhs jfhs commented Mar 23, 2017

IJsonApiContext.RelationshipsToUpdate is defined as Dictionary<RelationshipAttribute, object>, however RelationshipAttribute.Equals seems to compare only class name, and so, having several relationships of same type caused only first one to be saved with last one's id (which may work with autoincrement ids by chance, but immediately failed with Guids).

This PR adds correct Equals which checks name and type of relationship. Also adds ToString for easier debugging (I thought it is used for default Equals implementation).

I didn't want to create a full acceptance test for this case, just made unit tests.

@jfhs jfhs added the bug label Mar 23, 2017
Copy link
Contributor

@jaredcnance jaredcnance left a comment

Choose a reason for hiding this comment

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

LGTM - can you bump the patch version number and we can merge this in. Thanks!

@jaredcnance jaredcnance merged commit 2a8c633 into json-api-dotnet:master Mar 23, 2017
@jfhs jfhs deleted the fix-multirelationship-save branch March 23, 2017 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

2 participants