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

Commit 2eb454aa by Daniel Durante

Merge pull request #712 from seth-admittedly/postgres-milliseconds

Keep milliseconds in timestamps for postgres
2 parents 06eac066 1749f6ad
Showing with 5 additions and 5 deletions
......@@ -138,7 +138,7 @@ module.exports = (function() {
}
if (this.__options.timestamps && this.dataValues.hasOwnProperty(updatedAtAttr)) {
this.dataValues[updatedAtAttr] = values[updatedAtAttr] = Utils.now()
this.dataValues[updatedAtAttr] = values[updatedAtAttr] = Utils.now(this.sequelize.options.dialect)
}
var errors = this.validate()
......@@ -369,8 +369,8 @@ module.exports = (function() {
}
if (this.__options.timestamps) {
defaults[this.__options.underscored ? 'created_at' : 'createdAt'] = Utils.now()
defaults[this.__options.underscored ? 'updated_at' : 'updatedAt'] = Utils.now()
defaults[this.__options.underscored ? 'created_at' : 'createdAt'] = Utils.now(this.sequelize.options.dialect)
defaults[this.__options.underscored ? 'updated_at' : 'updatedAt'] = Utils.now(this.sequelize.options.dialect)
if (this.__options.paranoid) {
defaults[this.__options.underscored ? 'deleted_at' : 'deletedAt'] = null
......
......@@ -164,9 +164,9 @@ var Utils = module.exports = {
return subClass;
},
now: function() {
now: function(dialect) {
var now = new Date()
now.setMilliseconds(0)
if(dialect != "postgres") now.setMilliseconds(0)
return now
},
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!