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

Commit 6bf2a1df by Mick Hansen

Merge branch 'master' of github.com:sequelize/sequelize

2 parents 1c7db237 67082f0f
......@@ -177,6 +177,7 @@ module.exports = (function() {
replication: this.options.replication,
dialectModulePath: this.options.dialectModulePath,
maxConcurrentQueries: this.options.maxConcurrentQueries,
keepDefaultTimezone: this.options.keepDefaultTimezone,
dialectOptions: this.options.dialectOptions
};
......
......@@ -112,7 +112,13 @@ SqlString.arrayToList = function(array, timeZone, dialect, field) {
}
var ret = 'ARRAY[' + valstr + ']';
if (!!field && !!field.type) {
ret += '::' + field.type.replace(/\(\d+\)/g, '');
// Need to translate DATETIME to TIMESTAMP WITH TIME ZONE for Postgres here
// There has to be a better solution than this
if (dialect === "postgres") {
ret += '::' + field.type.replace(/\(\d+\)/g, '').replace(/DATETIME/, 'TIMESTAMP WITH TIME ZONE');
} else {
ret += '::' + field.type.replace(/\(\d+\)/g, '');
}
}
return ret;
} else {
......
......@@ -370,6 +370,26 @@ if (dialect.match(/^postgres/)) {
})
})
describe('timestamps', function () {
beforeEach( function (done) {
this.User = this.sequelize.define('User', {
dates : DataTypes.ARRAY(DataTypes.DATE)
})
this.User.sync({ force: true }).success(function() {
done()
})
})
it('should use postgres "TIMESTAMP WITH TIME ZONE" instead of "DATETIME"', function (done) {
this.User.create({
dates: []
}).on('sql', function(sql) {
expect(sql.indexOf('TIMESTAMP WITH TIME ZONE')).to.be.greaterThan(0)
done()
})
})
})
describe('model', function() {
it("create handles array correctly", function(done) {
this.User
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!