Skip to content
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

Merged
merged 1 commit into from
Jul 25, 2017

Conversation

stefanpenner
Copy link
Member

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

@stefanpenner stefanpenner changed the title [BUGFIX release] handle dupe relationship entries {MASTER} [BUGFIX release] handle dupe relationship entries Jul 24, 2017
Copy link
Member

@hjdivad hjdivad left a comment

Choose a reason for hiding this comment

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

LGTM (For merge)

  1. I'd prefer to see toString on the test models for easier debugging
  2. 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) {
Copy link
Member

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?

Copy link
Member Author

@stefanpenner stefanpenner Jul 24, 2017

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

Copy link
Member Author

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 })
});
Copy link
Member

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 })
});
Copy link
Member

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({
Copy link
Member

@hjdivad hjdivad Jul 24, 2017

Choose a reason for hiding this comment

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

❤️

@stefanpenner stefanpenner merged commit 4a366a1 into master Jul 25, 2017
@stefanpenner stefanpenner deleted the fix-dupes branch July 25, 2017 03:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants