-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
{MASTER} [BUGFIX release] handle dupe relationship entries #5088
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (For merge)
- I'd prefer to see
toString
on 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
@@ -201,17 +201,25 @@ export default class ManyRelationship extends Relationship { | |||
} | |||
|
|||
setInitialInternalModels(internalModels) { | |||
if (!internalModels) { | |||
if (Array.isArray(internalModels) === false || internalModels.length === 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not in a bugfix, I am fine with someone doing a follow up PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 }) | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+toString
?
const Person = DS.Model.extend({ | ||
name: DS.attr('string'), | ||
tag: DS.belongsTo('tag', { async: false }) | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+toString
?
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
people: DS.hasMany('person', { async: false }) | ||
}); | ||
|
||
Tag.reopenClass({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
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