Browse Source

Patch TypeORM to workaround typeorm/typeorm#3636

master
Menci 6 years ago
parent
commit
3281cbe474
  1. 14
      app.js

14
app.js

@ -125,6 +125,16 @@ global.syzoj = {
}); });
}, },
async connectDatabase() { async connectDatabase() {
// Patch TypeORM to workaround https://github.com/typeorm/typeorm/issues/3636
const TypeORMMysqlDriver = require('typeorm/driver/mysql/MysqlDriver');
const OriginalNormalizeType = TypeORMMysqlDriver.MysqlDriver.prototype.normalizeType;
TypeORMMysqlDriver.MysqlDriver.prototype.normalizeType = function (column) {
if (column.type === 'json') {
return 'longtext';
}
return OriginalNormalizeType(column);
};
const TypeORM = require('typeorm'); const TypeORM = require('typeorm');
global.TypeORM = TypeORM; global.TypeORM = TypeORM;
@ -134,7 +144,7 @@ global.syzoj = {
.filter(filename => filename.endsWith('.ts') && filename !== 'common.ts') .filter(filename => filename.endsWith('.ts') && filename !== 'common.ts')
.map(filename => require(modelsBuiltPath + filename.replace('.ts', '.js')).default); .map(filename => require(modelsBuiltPath + filename.replace('.ts', '.js')).default);
const connection = await TypeORM.createConnection({ await TypeORM.createConnection({
type: 'mariadb', type: 'mariadb',
host: this.config.db.host.split(':')[0], host: this.config.db.host.split(':')[0],
port: this.config.db.host.split(':')[1] || 3306, port: this.config.db.host.split(':')[1] || 3306,
@ -143,7 +153,7 @@ global.syzoj = {
database: this.config.db.database, database: this.config.db.database,
entities: models, entities: models,
synchronize: true, synchronize: true,
logging: false logging: true
}); });
}, },
loadModules() { loadModules() {

Loading…
Cancel
Save