Skip to content

Commit

Permalink
fix(query-generator): handle field names in scope include (#10718)
Browse files Browse the repository at this point in the history
  • Loading branch information
amitaymolko authored and sushantdhiman committed Apr 8, 2019
1 parent 75e363e commit 4c9d18f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/dialects/abstract/query-generator.js
Expand Up @@ -1426,6 +1426,8 @@ class QueryGenerator {
// includeIgnoreAttributes is used by aggregate functions
if (topLevelInfo.options.includeIgnoreAttributes !== false) {
include.model._expandAttributes(include);
Utils.mapOptionFieldNames(include, include.model);

const includeAttributes = include.attributes.map(attr => {
let attrAs = attr;
let verbatim = false;
Expand Down
6 changes: 5 additions & 1 deletion test/integration/model/scope/find.test.js
Expand Up @@ -47,7 +47,11 @@ describe(Support.getTestDialectTeaser('Model'), () => {
});

this.DefaultScopeExclude = this.sequelize.define('DefaultScopeExclude', {
name: Sequelize.STRING
name: Sequelize.STRING,
other_value: {
type: Sequelize.STRING,
field: 'otherValue'
}
}, {
defaultScope: {
attributes: {
Expand Down

0 comments on commit 4c9d18f

Please sign in to comment.