Skip to content

Commit

Permalink
Revert "Force UTC at process level"
Browse files Browse the repository at this point in the history
  • Loading branch information
ErisDS committed Jun 2, 2016
1 parent 3fcf863 commit 78e693f
Show file tree
Hide file tree
Showing 19 changed files with 40 additions and 583 deletions.
3 changes: 1 addition & 2 deletions Gruntfile.js
Expand Up @@ -176,8 +176,7 @@ var _ = require('lodash'),
ui: 'bdd',
reporter: grunt.option('reporter') || 'spec',
timeout: '15000',
save: grunt.option('reporter-output'),
require: ['core/server/overrides']
save: grunt.option('reporter-output')
},

// #### All Unit tests
Expand Down
24 changes: 3 additions & 21 deletions core/server/data/db/connection.js
@@ -1,17 +1,13 @@
var knex = require('knex'),
config = require('../../config'),
var knex = require('knex'),
config = require('../../config'),
dbConfig = config.database,
knexInstance;

function configure(dbConfig) {
var client = dbConfig.client,
pg;

dbConfig.isPostgreSQL = function () {
return client === 'pg' || client === 'postgres' || client === 'postgresql';
};

if (dbConfig.isPostgreSQL()) {
if (client === 'pg' || client === 'postgres' || client === 'postgresql') {
try {
pg = require('pg');
} catch (e) {
Expand All @@ -24,26 +20,12 @@ function configure(dbConfig) {
pg.types.setTypeParser(20, function (val) {
return val === null ? null : parseInt(val, 10);
});

// https://github.com/tgriesser/knex/issues/97
// this sets the timezone to UTC only for the connection!
dbConfig.pool = {
afterCreate: function (connection, callback) {
connection.query('set timezone=\'UTC\'', function (err) {
callback(err, connection);
});
}
};
}

if (client === 'sqlite3') {
dbConfig.useNullAsDefault = dbConfig.useNullAsDefault || false;
}

if (client === 'mysql') {
dbConfig.connection.timezone = 'UTC';
}

return dbConfig;
}

Expand Down
1 change: 0 additions & 1 deletion core/server/data/migration/006/index.js

This file was deleted.

209 changes: 0 additions & 209 deletions core/server/data/migration/fixtures/006/01-transform-dates-into-utc.js

This file was deleted.

3 changes: 0 additions & 3 deletions core/server/data/migration/fixtures/006/index.js

This file was deleted.

5 changes: 1 addition & 4 deletions core/server/data/schema/default-settings.json
@@ -1,7 +1,7 @@
{
"core": {
"databaseVersion": {
"defaultValue": "006"
"defaultValue": "005"
},
"dbHash": {
"defaultValue": null
Expand All @@ -11,9 +11,6 @@
},
"displayUpdateNotification": {
"defaultValue": null
},
"migrations": {
"defaultValue": "{}"
}
},
"blog": {
Expand Down
7 changes: 4 additions & 3 deletions core/server/data/validation/index.js
Expand Up @@ -5,8 +5,9 @@ var schema = require('../schema').tables,
Promise = require('bluebird'),
errors = require('../../errors'),
config = require('../../config'),
readThemes = require('../../utils/read-themes'),
readThemes = require('../../utils/read-themes'),
i18n = require('../../i18n'),
toString = require('lodash.tostring'),

validateSchema,
validateSettings,
Expand Down Expand Up @@ -53,7 +54,7 @@ validateSchema = function validateSchema(tableName, model) {

_.each(columns, function each(columnKey) {
var message = '',
strVal = _.toString(model[columnKey]);
strVal = toString(model[columnKey]);

// check nullable
if (model.hasOwnProperty(columnKey) && schema[tableName][columnKey].hasOwnProperty('nullable')
Expand Down Expand Up @@ -165,7 +166,7 @@ validateActiveTheme = function validateActiveTheme(themeName) {
// available validators: https://github.com/chriso/validator.js#validators
validate = function validate(value, key, validations) {
var validationErrors = [];
value = _.toString(value);
value = toString(value);

_.each(validations, function each(validationOptions, validationName) {
var goodResult = true;
Expand Down

0 comments on commit 78e693f

Please sign in to comment.