不要怂,就是干,撸起袖子干!

Commit b72e3bb2 by bparan Committed by Sushant

fix(query-generator): handle virtual column on associations with scopes (#11327)

1 parent 801aa365
...@@ -1455,7 +1455,7 @@ class QueryGenerator { ...@@ -1455,7 +1455,7 @@ class QueryGenerator {
// includeIgnoreAttributes is used by aggregate functions // includeIgnoreAttributes is used by aggregate functions
if (topLevelInfo.options.includeIgnoreAttributes !== false) { if (topLevelInfo.options.includeIgnoreAttributes !== false) {
include.model._expandAttributes(include); include.model._expandAttributes(include);
Utils.mapOptionFieldNames(include, include.model); Utils.mapFinderOptions(include, include.model);
const includeAttributes = include.attributes.map(attr => { const includeAttributes = include.attributes.map(attr => {
let attrAs = attr; let attrAs = attr;
......
...@@ -142,4 +142,40 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -142,4 +142,40 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}); });
}); });
}); });
describe('scope in associations', () => {
it('should work when association with a virtual column queried with default scope', function() {
const Game = this.sequelize.define('Game', {
name: Sequelize.TEXT
});
const User = this.sequelize.define('User', {
login: Sequelize.TEXT,
session: {
type: Sequelize.VIRTUAL,
get() {
return 'New';
}
}
}, {
defaultScope: {
attributes: {
exclude: ['login']
}
}
});
Game.hasMany(User);
return this.sequelize.sync({ force: true }).then(() => {
return Game.findAll({
include: [{
model: User
}]
});
}).then(games => {
expect(games).to.have.lengthOf(0);
});
});
});
}); });
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!