{MASTER} [BUGFIX release] handle dupe relationship entries - #5088
Merged
Conversation
hjdivad
approved these changes
Jul 24, 2017
hjdivad
left a comment
Contributor
There was a problem hiding this comment.
LGTM (For merge)
- I'd prefer to see
toStringon the test models for easier debugging - Unclear to me why we can't pull the runtime validation checks to public API
Both of the above are minor issues though
|
|
||
| setInitialInternalModels(internalModels) { | ||
| if (!internalModels) { | ||
| if (Array.isArray(internalModels) === false || internalModels.length === 0) { |
Contributor
There was a problem hiding this comment.
Seems okay but this feel pretty deep internally for checking input validity; IIRC we already have a dev assertion to this effect at the store API.
Can we move this kind of validation up to public APIs?
Contributor
Author
There was a problem hiding this comment.
not in a bugfix, I am fine with someone doing a follow up PR
Contributor
Author
There was a problem hiding this comment.
Also, the above was more of a refinement on the existing code. But yes, a future cleanup PR sounds good.
| const Tag = DS.Model.extend({ | ||
| name: DS.attr('string'), | ||
| people: DS.hasMany('person', { async: false }) | ||
| }); |
| const Person = DS.Model.extend({ | ||
| name: DS.attr('string'), | ||
| tag: DS.belongsTo('tag', { async: false }) | ||
| }); |
If a relationship was setup with duplicate entries, it would enter an invalid state. Specifically, this.canonicalMembers and this.canonicalState would be out of sync. Resulting in some sad things. This was most likely introduced by f8304b2#commitcomment-23256408
hjdivad
reviewed
Jul 24, 2017
| people: DS.hasMany('person', { async: false }) | ||
| }); | ||
|
|
||
| Tag.reopenClass({ |
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.
If a relationship was setup with duplicate entries, it would enter an
invalid state. Specifically, this.canonicalMembers and
this.canonicalState would be out of sync. Resulting in some sad things.
This was most likely introduced by f8304b2#commitcomment-23256408