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

Commit 2a5773a4 by Sushant Committed by Mick Hansen

Fix #5057, Count no longer include attributes (#6096)

* (test) count() should return attributes

* count use explicit attributes from options

* count with attributes return string
1 parent a33dbf3a
......@@ -2,6 +2,7 @@
- [CHANGED] Range type bounds now default to [postgres default](https://www.postgresql.org/docs/9.5/static/rangetypes.html#RANGETYPES-CONSTRUCT) `[)` (inclusive, exclusive) [#5990](https://github.com/sequelize/sequelize/issues/5990)
- [ADDED] Support for range operators [#5990](https://github.com/sequelize/sequelize/issues/5990)
- [FIXED] Broken transactions in `MySQL` [#3568](https://github.com/sequelize/sequelize/issues/3568)
- [FIXED] `Model.count` don't include attributes [#5057](https://github.com/sequelize/sequelize/issues/5057)
## BC breaks:
- Range type bounds now default to [postgres default](https://www.postgresql.org/docs/9.5/static/rangetypes.html#RANGETYPES-CONSTRUCT) `[)` (inclusive, exclusive), previously was `()` (exclusive, exclusive)
......
......@@ -1545,6 +1545,7 @@ class Model {
_.defaults(options, { hooks: true });
let col = '*';
let attributes = options.attributes;
return Promise.try(() => {
this._conformOptions(options, this);
......@@ -1568,7 +1569,7 @@ class Model {
options.limit = null;
options.offset = null;
options.order = null;
options.attributes = [];
options.attributes = attributes || [];
return this.aggregate(col, 'count', options);
});
......
......@@ -51,5 +51,26 @@ describe(Support.getTestDialectTeaser('Model'), function() {
}]
})).to.eventually.equal(1);
});
it('should return attributes', function () {
return this.User.create({
username: 'valak',
createdAt: (new Date()).setFullYear(2015)
})
.then(() =>
this.User.count({
attributes: ['createdAt'],
group: ['createdAt']
})
)
.then((users) => {
expect(users.length).to.be.eql(2);
// have attributes
expect(users[0].createdAt).to.exist;
expect(users[1].createdAt).to.exist;
});
});
});
});
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!