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

Commit 5ecec7ec by Matt Broadstone

stop sequelize from erroneously adding timezone to raw query dates

Only for rawSelects it seems that Sequelize forcibly adds timezone
information to dates returned from the database. This breaks in
strange and magical ways
1 parent 408d54ea
...@@ -684,7 +684,9 @@ module.exports = (function() { ...@@ -684,7 +684,9 @@ module.exports = (function() {
} else if (dataType === DataTypes.INTEGER || dataType instanceof DataTypes.BIGINT) { } else if (dataType === DataTypes.INTEGER || dataType instanceof DataTypes.BIGINT) {
result = parseInt(result, 10); result = parseInt(result, 10);
} else if (dataType === DataTypes.DATE) { } else if (dataType === DataTypes.DATE) {
result = new Date(result + self.sequelize.options.timezone); if (!Utils._.isDate(result)) {
result = new Date(result);
}
} else if (dataType === DataTypes.STRING) { } else if (dataType === DataTypes.STRING) {
// Nothing to do, result is already a string. // Nothing to do, result is already a string.
} }
......
...@@ -1727,14 +1727,17 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -1727,14 +1727,17 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
it("should allow dates in max", function(done) { it("should allow dates in max", function(done) {
var self = this var self = this
this.User.bulkCreate([{theDate: new Date(2013, 12, 31)}, {theDate: new Date(2000, 01, 01)}]).success(function(){ this.User.bulkCreate([
self.User.max('theDate').success(function(max){ {theDate: new Date(2013, 11, 31)},
{theDate: new Date(2000, 01, 01)}
]).success(function() {
self.User.max('theDate').success(function(max) {
expect(max).to.be.a('Date'); expect(max).to.be.a('Date');
expect(max).to.equalDate(new Date(2013, 12, 31)) expect(max).to.equalDate(new Date(2013, 11, 31));
done() done();
}) });
}) });
}) });
it("should allow strings in max", function(done) { it("should allow strings in max", function(done) {
var self = this var self = this
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!