You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Literal queries not getting evaluated on through attributes #5602
In a belongsToMany association, Sequelize.literal attributes do not show up in the response:
...
include: [{
model: ModelA,
attributes: [[Sequelize.literal('3'), 'normaltest']], // Shows up in response as ModelA.normaltest: 3
through: {
attributes: [[Sequelize.literal('3'), 'throughtest']] // Does not show up
}
}]
...
I have used sequelize.literal in attributes but not working.
Throwing error
attr[0].includes is not a function
at attributes.map.attr (sequelize/lib/dialects/abstract/query-generator.js:1382:29)
when I removed the literal it is working.
But I want to calculate distinct count of an item.
like this:
Sequelize.literal('count(distinct('id'))')
Reacted by Mariany Ferreira da Silva, Kritsada Sunthornwutthikrai, Gary McMeekin and ykaty honey
Activity
xizhao commentedon Mar 16, 2016
A greater issue seems to be I am not able to specify which attributes are getting selected,
i.e.
attributes: ['attr1', 'attr2']yields the same results atattributes: ['attr1']mickhansen commentedon Mar 17, 2016
Please move the second comment seperate issue and show some code that verifies it.
I can see definitely see mappings not working for through.attributes
xizhao commentedon May 17, 2016
If #1 is a symptom of #2, should we just rename this issue to that?
janmeier commentedon May 17, 2016
@xizhao I believe they are two separate issues
PragnaGH commentedon Mar 27, 2019
I am using sequelize 5.2.1
I have used sequelize.literal in attributes but not working.
Throwing error
attr[0].includes is not a function
at attributes.map.attr (sequelize/lib/dialects/abstract/query-generator.js:1382:29)
when I removed the literal it is working.
But I want to calculate distinct count of an item.
like this:
Sequelize.literal('count(distinct('id'))')
marianyfs commentedon Aug 22, 2019