-
-
Notifications
You must be signed in to change notification settings - Fork 195
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: fetch all nested relations #273
Conversation
I've tried to run tests on Node v9.3; the went without any errors. |
@thetutlage is it possible to restart CI builds? |
I have started the Jobs. Also would you mind adding a deep nested relationship test too, just. want to make sure there is no edge case here. That will be having class Part extends Model {
}
class Car extends Model {
parts () {
this.hasMany(Part)
}
} And doing with('user.car.parts') |
Sure will add it.
Thank you. |
src/Lucid/EagerLoad/index.js
Outdated
const name = _.first(_.keys(nested)) | ||
relatedQuery.with(name, nested[name]) | ||
} | ||
Object.entries(nested || {}) |
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.
Also try using _.each
here, just that we use lodash everywhere
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.
Was wondering about this - do we need it? I mean, most use cases of lodash can be done easily using native API.
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.
Yeah but once project is using it, there is no point is mixing both. So until lodash stays, I prefer keeping it uniformed
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 don't agree with you on that, yet I'll update PR to your request :)
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.
Fixed in 3676b2e
@thetutlage I've added new test case in 75939ad |
src/Lucid/EagerLoad/index.js
Outdated
const name = _.first(_.keys(nested)) | ||
relatedQuery.with(name, nested[name]) | ||
} | ||
Object.entries(nested || {}) |
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.
Yeah but once project is using it, there is no point is mixing both. So until lodash stays, I prefer keeping it uniformed
Thank you! |
When fetching more than one nested relation lucid included only the first one.
This PR provides a simple fix for this issue.