-
Notifications
You must be signed in to change notification settings - Fork 363
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 for issues #622 & #623 #626
Conversation
polymorphic hasOne needs separate handling and hasMany->referencesMany has a unique case which is fixed for MongoDB as suggested by @fabien.
LGTM. @fabien Please review. |
async.each(targets, linkOneToOne, next); | ||
function linkOneToOne(target, next) { | ||
var sourceId = target[relation.keyTo]; | ||
var obj = objIdMap[sourceId.toString()]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should check that obj
is actually defined at this stage (defensive coding ...)? There are probably other parts of this code where this might be appropriate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that it makes sense only for the referencesMany -> hasMany case because it is possible to have no value for a map key. In other cases, it should always have a map entry.
@raymondfeng other than the comment, LGTM |
@ningsuhen Can you address the comment from @fabien so that we can merge the PR? |
@raymondfeng , I had replied to the comment. I think it is applicable only in case of referencesMany <-> hasMany because |
@raymondfeng LGTM |
@fabien, @raymondfeng , I have added the checks anyway :). |
Fix for issues #622 & #623
polymorphic hasOne needs separate handling and hasMany->referencesMany has a unique case which is fixed for MongoDB as suggested by @fabien.