fix(hasOne): do not create links for undefined or null keys by nickescallon · Pull Request #379 · js-data/js-data

Skip to content

Navigation Menu

Sign in

Appearance settings

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

Conversation

@nickescallon

Copy link Copy Markdown

Contributor

@nickescallon nickescallon commented

Aug 1, 2016

edited

Loading

hasOne links were being created in cases they should not.

  • when no link existed, foreignKey was undefined
  • we tried to filter on relatedCollection where the foreignKey === undefined
  • this returned the entire set of records that did not actually have any related records, where in fact we don't want to find any relations in this case.
findExistingLinksByForeignKey (id) {
if (id === undefined || id === null) {
return
}
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.

or we could rework this method such that it returns an empty array in this case.

@Pargus

Copy link Copy Markdown

Pargus commented

Aug 2, 2016

Issue with Plunkers showing the bug: #380

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

3.0.0 Release Candidate

Development

Successfully merging this pull request may close these issues.

3 participants

@nickescallon @Pargus @jmdobry