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: fetch all nested relations #273

Merged
merged 4 commits into from
Jan 5, 2018
Merged

Fix: fetch all nested relations #273

merged 4 commits into from
Jan 5, 2018

Conversation

radmen
Copy link
Contributor

@radmen radmen commented Jan 4, 2018

When fetching more than one nested relation lucid included only the first one.
This PR provides a simple fix for this issue.

@radmen
Copy link
Contributor Author

radmen commented Jan 4, 2018

I've tried to run tests on Node v9.3; the went without any errors.
Any idea why they fail on AppVeyor?

@coveralls
Copy link

coveralls commented Jan 4, 2018

Coverage Status

Coverage decreased (-0.003%) to 96.333% when pulling d713f01 on radmen:fix-fetch-all-relations into 5703a7c on adonisjs:develop.

@radmen
Copy link
Contributor Author

radmen commented Jan 5, 2018

@thetutlage is it possible to restart CI builds?

@thetutlage
Copy link
Member

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 parts relationship on the Car Model.

class Part extends Model {
}

class Car extends Model {
  parts () {
    this.hasMany(Part)
  }
}

And doing

with('user.car.parts')

@radmen
Copy link
Contributor Author

radmen commented Jan 5, 2018

Also would you mind adding a deep nested relationship test too, just. want to make sure there is no edge case here.

Sure will add it.

I have started the Jobs.

Thank you.

const name = _.first(_.keys(nested))
relatedQuery.with(name, nested[name])
}
Object.entries(nested || {})
Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Member

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

Copy link
Contributor Author

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 :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 3676b2e

@radmen
Copy link
Contributor Author

radmen commented Jan 5, 2018

@thetutlage I've added new test case in 75939ad

@coveralls
Copy link

coveralls commented Jan 5, 2018

Coverage Status

Coverage decreased (-0.003%) to 96.333% when pulling 75939ad on radmen:fix-fetch-all-relations into 5703a7c on adonisjs:develop.

const name = _.first(_.keys(nested))
relatedQuery.with(name, nested[name])
}
Object.entries(nested || {})
Copy link
Member

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

@coveralls
Copy link

coveralls commented Jan 5, 2018

Coverage Status

Coverage decreased (-0.003%) to 96.333% when pulling 3676b2e on radmen:fix-fetch-all-relations into 5703a7c on adonisjs:develop.

@thetutlage thetutlage merged commit 1a796cd into adonisjs:develop Jan 5, 2018
@radmen radmen deleted the fix-fetch-all-relations branch January 6, 2018 15:04
@radmen
Copy link
Contributor Author

radmen commented Jan 6, 2018

Thank you!

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