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

Commit ae89e846 by Jan Aagaard Meier

Merge pull request #5273 from karthikv/postgres-timezone

Fix setting postgres timezone while fetching hstore oids.
2 parents 9aa3773f 6dda277c
......@@ -132,7 +132,7 @@ ConnectionManager.prototype.connect = function(config) {
if (!self.sequelize.config.keepDefaultTimezone) {
var isZone = !!moment.tz.zone(self.sequelize.options.timezone);
if (isZone) {
query += 'SET client_min_messages TO warning; SET TIME ZONE \'' + self.sequelize.options.timezone + '\'';
query += 'SET client_min_messages TO warning; SET TIME ZONE \'' + self.sequelize.options.timezone + '\';';
} else {
query += 'SET client_min_messages TO warning; SET TIME ZONE INTERVAL \'' + self.sequelize.options.timezone + '\' HOUR TO MINUTE;';
}
......
......@@ -10,8 +10,8 @@ var chai = require('chai')
if (dialect.match(/^postgres/)) {
describe('[POSTGRES] Sequelize', function() {
it('should correctly parse the moment based timezone', function() {
var options = _.extend(this.sequelize.options, { timezone: 'Asia/Kolkata', timestamps: true });
function checkTimezoneParsing(baseOptions) {
var options = _.extend({}, baseOptions, { timezone: 'Asia/Kolkata', timestamps: true });
var sequelize = Support.createSequelizeInstance(options);
var tzTable = sequelize.define('tz_table', { foo: DataTypes.STRING });
......@@ -20,6 +20,17 @@ if (dialect.match(/^postgres/)) {
expect(row).to.be.not.null;
});
});
}
it('should correctly parse the moment based timezone', function() {
return checkTimezoneParsing(this.sequelize.options);
});
it('should correctly parse the moment based timezone while fetching hstore oids', function() {
// reset oids so we need to refetch them
DataTypes.HSTORE.types.postgres.oids = [];
DataTypes.HSTORE.types.postgres.array_oids = [];
return checkTimezoneParsing(this.sequelize.options);
});
});
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!