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

Commit c5cccd41 by Richard Comley

fixes problem with order in scope when counting

having order option in model’s scope when performing a count kicked out
this error:

SequelizeDatabaseError: column “xxxx” must appear in the GROUP BY
clause or be used in an aggregate function
1 parent c38aa5f7
...@@ -1345,6 +1345,7 @@ Model.prototype.count = function(options) { ...@@ -1345,6 +1345,7 @@ Model.prototype.count = function(options) {
options.dataType = new DataTypes.INTEGER(); options.dataType = new DataTypes.INTEGER();
options.includeIgnoreAttributes = false; options.includeIgnoreAttributes = false;
options.limit = null; options.limit = null;
options.order = null;
return this.aggregate(col, 'count', options); return this.aggregate(col, 'count', options);
}; };
......
...@@ -31,6 +31,9 @@ describe(Support.getTestDialectTeaser('Model'), function() { ...@@ -31,6 +31,9 @@ describe(Support.getTestDialectTeaser('Model'), function() {
lte: 5 lte: 5
} }
} }
},
withOrder: {
order: 'username'
} }
} }
}); });
...@@ -65,6 +68,10 @@ describe(Support.getTestDialectTeaser('Model'), function() { ...@@ -65,6 +68,10 @@ describe(Support.getTestDialectTeaser('Model'), function() {
it('should be able to merge scopes with where', function () { it('should be able to merge scopes with where', function () {
return expect(this.ScopeMe.scope('lowAccess').count({ where: { username: 'dan'}})).to.eventually.equal(1); return expect(this.ScopeMe.scope('lowAccess').count({ where: { username: 'dan'}})).to.eventually.equal(1);
}); });
it('should ignore the order option if it is found within the scope', function () {
return expect(this.ScopeMe.scope('withOrder').count()).to.eventually.equal(4);
});
}); });
}); });
}); });
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!