Skip to content

{MASTER} [BUGFIX release] handle dupe relationship entries - #5088

Merged
stefanpenner merged 1 commit into
masterfrom
fix-dupes
Jul 25, 2017
Merged

{MASTER} [BUGFIX release] handle dupe relationship entries#5088
stefanpenner merged 1 commit into
masterfrom
fix-dupes

Conversation

@stefanpenner

Copy link
Copy Markdown
Contributor

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 requested a review from hjdivad July 24, 2017 05:00
@stefanpenner stefanpenner changed the title [BUGFIX release] handle dupe relationship entries {MASTER} [BUGFIX release] handle dupe relationship entries Jul 24, 2017

@hjdivad hjdivad left a comment

Copy link
Copy Markdown
Contributor

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


setInitialInternalModels(internalModels) {
if (!internalModels) {
if (Array.isArray(internalModels) === false || internalModels.length === 0) {

Copy link
Copy Markdown
Contributor

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?

@stefanpenner stefanpenner Jul 24, 2017

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
Contributor 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
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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({

@hjdivad hjdivad Jul 24, 2017

Copy link
Copy Markdown
Contributor

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.

2 participants