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

fix(hasOne): do not create links for undefined or null keys #379

Merged
merged 1 commit into from Aug 3, 2016

Conversation

nickescallon
Copy link
Contributor

@nickescallon nickescallon commented Aug 1, 2016

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.

@@ -193,6 +193,9 @@ utils.addHiddenPropsToTarget(Relation.prototype, {

// e.g. user hasMany post via "foreignKey", so find all posts of user
findExistingLinksByForeignKey (id) {
if (id === undefined || id === null) {
return
}
Copy link
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

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants