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

Invalid query bindings on relation belongsTo #165

Merged
merged 4 commits into from
Aug 26, 2017
Merged

Invalid query bindings on relation belongsTo #165

merged 4 commits into from
Aug 26, 2017

Conversation

ntvsx193
Copy link
Contributor

Fix for #164

@coveralls
Copy link

coveralls commented Aug 24, 2017

Coverage Status

Coverage increased (+0.009%) to 97.394% when pulling 5071a5a on ntvsx193:develop into 08503da on adonisjs:develop.

@coveralls
Copy link

coveralls commented Aug 24, 2017

Coverage Status

Coverage increased (+0.04%) to 97.428% when pulling f5b11f4 on ntvsx193:develop into 08503da on adonisjs:develop.

@@ -32,7 +32,13 @@ class BelongsTo extends BaseRelation {
* @return {Array}
*/
mapValues (modelInstances) {
return _.map(modelInstances, (modelInstance) => modelInstance[this.primaryKey])
const values = []
Copy link
Member

Choose a reason for hiding this comment

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

It can be done in one line using the _.transform method of lodash. I don't like the idea of intermediate variables

Copy link
Member

@thetutlage thetutlage Aug 25, 2017

Choose a reason for hiding this comment

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

What u can do is

_.transform(modelInstances, (result, modelInstance) => {
   if (modelInstance[this.primaryKey]) {
     result.push(modelInstance[this.primaryKey])
   }
   return result
}, [])

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thx, my knowledge is small in lodash.
I will try use _.transform and send changes

@@ -32,7 +32,13 @@ class BelongsTo extends BaseRelation {
* @return {Array}
*/
mapValues (modelInstances) {
return _.map(modelInstances, (modelInstance) => modelInstance[this.primaryKey])
const values = []
Copy link
Member

@thetutlage thetutlage Aug 25, 2017

Choose a reason for hiding this comment

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

What u can do is

_.transform(modelInstances, (result, modelInstance) => {
   if (modelInstance[this.primaryKey]) {
     result.push(modelInstance[this.primaryKey])
   }
   return result
}, [])

Copy link
Contributor Author

@ntvsx193 ntvsx193 left a comment

Choose a reason for hiding this comment

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

I send changes, u can see it

@@ -32,7 +32,13 @@ class BelongsTo extends BaseRelation {
* @return {Array}
*/
mapValues (modelInstances) {
return _.map(modelInstances, (modelInstance) => modelInstance[this.primaryKey])
const values = []
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thx, my knowledge is small in lodash.
I will try use _.transform and send changes

@coveralls
Copy link

coveralls commented Aug 25, 2017

Coverage Status

Coverage increased (+0.03%) to 97.417% when pulling 4eb520a on ntvsx193:develop into 08503da on adonisjs:develop.

@thetutlage
Copy link
Member

This looks better

@thetutlage thetutlage merged commit 95553be into adonisjs:develop Aug 26, 2017
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