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

Commit 364e601d by Jan Aagaard Meier

bug(scopes) Fix addscope when model does not have any inital scopes. Closes #4243

1 parent 5858e027
# Next # Next
- [FIXED] Map column names with `.field` in scopes with includes. [#4210](https://github.com/sequelize/sequelize/issues/4210) - [FIXED] Map column names with `.field` in scopes with includes. [#4210](https://github.com/sequelize/sequelize/issues/4210)
- [FIXED] `addScope` when the model does not have any initial scopes [#4243](https://github.com/sequelize/sequelize/issues/4243)
# 3.5.1 # 3.5.1
- [FIXED] Fix bug with nested includes where a middle include results in a null value which breaks $findSeperate. - [FIXED] Fix bug with nested includes where a middle include results in a null value which breaks $findSeperate.
......
...@@ -36,7 +36,7 @@ var Model = function(name, attributes, options) { ...@@ -36,7 +36,7 @@ var Model = function(name, attributes, options) {
schema: null, schema: null,
schemaDelimiter: '', schemaDelimiter: '',
defaultScope: null, defaultScope: null,
scopes: null, scopes: [],
hooks: {}, hooks: {},
indexes: [] indexes: []
}, options || {}); }, options || {});
...@@ -1342,7 +1342,7 @@ Model.$findSeperate = function(results, options) { ...@@ -1342,7 +1342,7 @@ Model.$findSeperate = function(results, options) {
var original = results; var original = results;
if (options.plain) results = [results]; if (options.plain) results = [results];
if (!results.length) return original; if (!results.length) return original;
return Promise.map(options.include, function (include) { return Promise.map(options.include, function (include) {
......
...@@ -158,6 +158,14 @@ describe(Support.getTestDialectTeaser('Model'), function() { ...@@ -158,6 +158,14 @@ describe(Support.getTestDialectTeaser('Model'), function() {
}); });
describe('addScope', function () { describe('addScope', function () {
it('works if the model does not have any initial scopes', function () {
var Model = current.define('model');
expect(function () {
Model.addScope('anything', {});
}).not.to.throw();
});
it('allows me to add a new scope', function () { it('allows me to add a new scope', function () {
expect(function () { expect(function () {
Company.scope('newScope'); Company.scope('newScope');
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!