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

Commit 3ed0c088 by Sushant Committed by GitHub

fix(scope): symbol operators are ignored (#8863)

1 parent 14864d48
...@@ -1401,7 +1401,7 @@ class Model { ...@@ -1401,7 +1401,7 @@ class Model {
if (scope) { if (scope) {
_.assignWith(self._scope, scope, (objectValue, sourceValue, key) => { _.assignWith(self._scope, scope, (objectValue, sourceValue, key) => {
if (key === 'where') { if (key === 'where') {
return Array.isArray(sourceValue) ? sourceValue : _.assign(objectValue || {}, sourceValue); return Array.isArray(sourceValue) ? sourceValue : Object.assign(objectValue || {}, sourceValue);
} else if (['attributes', 'include', 'group'].indexOf(key) >= 0 && Array.isArray(objectValue) && Array.isArray(sourceValue)) { } else if (['attributes', 'include', 'group'].indexOf(key) >= 0 && Array.isArray(objectValue) && Array.isArray(sourceValue)) {
return objectValue.concat(sourceValue); return objectValue.concat(sourceValue);
} }
......
...@@ -25,6 +25,14 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -25,6 +25,14 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}, },
withName: { withName: {
attributes: ['username'] attributes: ['username']
},
highAccess: {
where: {
[Sequelize.Op.or]: [
{ access_level: { [Sequelize.Op.gte]: 5 } },
{ access_level: { [Sequelize.Op.eq]: 10 } }
]
}
} }
} }
}); });
...@@ -48,5 +56,12 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -48,5 +56,12 @@ describe(Support.getTestDialectTeaser('Model'), () => {
expect(record.access_level).to.exist; expect(record.access_level).to.exist;
}); });
}); });
it('should work with Symbol operators', function() {
return this.ScopeMe.scope('highAccess').findOne()
.then(record => {
expect(record.username).to.equal('tobi');
});
});
}); });
}); });
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!