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

Commit 5a36157e by Jan Aagaard Meier

Merge pull request #5274 from sequelize/4958merge

Reroll #4958
2 parents 967b9d08 4d0af10d
......@@ -99,6 +99,13 @@ module.exports = function (BaseTypes) {
return 'DATETIME2';
};
DATE.prototype.$stringify = function (date, options) {
date = this.$applyTimezone(date, options);
// mssql not allow +timezone datetime format
return date.format('YYYY-MM-DD HH:mm:ss.SSS');
};
var INTEGER = BaseTypes.INTEGER.inherits(function() {
if (!(this instanceof INTEGER)) return new INTEGER();
BaseTypes.INTEGER.apply(this, arguments);
......
......@@ -36,6 +36,30 @@ describe(Support.getTestDialectTeaser('SQL'), function() {
});
describe('dates', function () {
it('formats the date correctly when inserting', function () {
var timezoneSequelize = Support.createSequelizeInstance({
timezone: Support.getTestDialect() === 'sqlite' ? '+00:00' : 'CET'
});
var User = timezoneSequelize.define('user', {
date: {
type: DataTypes.DATE
}
},{
timestamps:false
});
expectsql(timezoneSequelize.dialect.QueryGenerator.insertQuery(User.tableName, {date: new Date(Date.UTC(2015, 0, 20))}, User.rawAttributes, {}),
{
postgres: 'INSERT INTO "users" ("date") VALUES (\'2015-01-20 01:00:00.000 +01:00\');',
sqlite: 'INSERT INTO `users` (`date`) VALUES (\'2015-01-20 00:00:00.000 +00:00\');',
mssql: 'INSERT INTO [users] ([date]) VALUES (N\'2015-01-20 01:00:00.000\');',
mysql: "INSERT INTO `users` (`date`) VALUES ('2015-01-20 01:00:00');"
});
});
});
describe('bulkCreate', function () {
it('bulk create with onDuplicateKeyUpdate', function () {
// Skip mssql for now, it seems broken
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!