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

Commit 7b740c76 by Mick Hansen

Merge pull request #2667 from mbroadst/fix-raw-select-date-time

stop sequelize from erroneously adding timezone to raw query dates
2 parents cea31050 5ecec7ec
...@@ -705,7 +705,9 @@ module.exports = (function() { ...@@ -705,7 +705,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!