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

Report errors for missing id properties for include #1642

Merged
merged 1 commit into from Oct 19, 2018
Merged

Conversation

raymondfeng
Copy link
Contributor

@raymondfeng raymondfeng commented Oct 18, 2018

strongloop/loopback#4028

Description

Related issues

  • connect to <link_to_referenced_issue>

Checklist

  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style
    guide

Copy link
Contributor

@b-admike b-admike left a comment

Choose a reason for hiding this comment

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

LGTM 🎉

User.findOne({include: {relation: 'profile'}, fields: 'name'}, function(err, user) {
should.not.exist(err);
should.exist(user);
should.not.exist(user.toJSON().profile);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if we should error out here as well and say that the id property is missing. Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For belongsTo and hasOne, the FK can be null from business function perspective. We can have an option to report as errors if necessary.

Copy link
Member

@bajtos bajtos left a comment

Choose a reason for hiding this comment

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

I am not familiar with this part of our codebase, thus I am not able to fully asses the changes. I don't see any obvious problem though.

Please improve the newly added tests per my comments below.

test/include.test.js Show resolved Hide resolved
test/include.test.js Outdated Show resolved Hide resolved
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

3 participants