diff --git a/gulpfile.js b/gulpfile.js index 650efd2..0ff84e2 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -24,7 +24,7 @@ gulp.task('clean', function () { gulp.task('prettier', function () { return gulp.src('.prettierrc') .pipe(shell(['prettier ./src/**/*.ts --write'])) - .pipe(shell(['prettier ./test/**/*.ts --write'])) + // .pipe(shell(['prettier ./test/**/*.ts --write'])) }); gulp.task('pre-commit', ['prettier'], function () { diff --git a/src/drivers/AbstractDriver.ts b/src/drivers/AbstractDriver.ts index 7bdfddf..c5494f4 100644 --- a/src/drivers/AbstractDriver.ts +++ b/src/drivers/AbstractDriver.ts @@ -15,11 +15,14 @@ export abstract class AbstractDriver { ): Promise { let dbModel = {}; await this.ConnectToServer(database, server, port, user, password, ssl); - let sqlEscapedSchema='\''+ schema.split(',').join('\',\'')+'\'' + let sqlEscapedSchema = "'" + schema.split(",").join("','") + "'"; dbModel.entities = await this.GetAllTables(sqlEscapedSchema); await this.GetCoulmnsFromEntity(dbModel.entities, sqlEscapedSchema); await this.GetIndexesFromEntity(dbModel.entities, sqlEscapedSchema); - dbModel.entities = await this.GetRelations(dbModel.entities, sqlEscapedSchema); + dbModel.entities = await this.GetRelations( + dbModel.entities, + sqlEscapedSchema + ); await this.DisconnectFromServer(); this.FindPrimaryColumnsFromIndexes(dbModel); return dbModel; diff --git a/src/drivers/MssqlDriver.ts b/src/drivers/MssqlDriver.ts index c1515d5..9c56fde 100644 --- a/src/drivers/MssqlDriver.ts +++ b/src/drivers/MssqlDriver.ts @@ -43,7 +43,7 @@ export class MssqlDriver extends AbstractDriver { response.forEach(val => { let ent: EntityInfo = new EntityInfo(); ent.EntityName = val.TABLE_NAME; - ent.Schema=val.TABLE_SCHEMA; + ent.Schema = val.TABLE_SCHEMA; ent.Columns = []; ent.Indexes = []; ret.push(ent); @@ -239,7 +239,11 @@ export class MssqlDriver extends AbstractDriver { break; default: TomgUtils.LogFatalError( - `Unknown column type: ${resp.DATA_TYPE} table name: ${resp.TABLE_NAME} column name: ${resp.COLUMN_NAME}` + `Unknown column type: ${ + resp.DATA_TYPE + } table name: ${ + resp.TABLE_NAME + } column name: ${resp.COLUMN_NAME}` ); break; } diff --git a/src/drivers/MysqlDriver.ts b/src/drivers/MysqlDriver.ts index 68d4d62..e631edf 100644 --- a/src/drivers/MysqlDriver.ts +++ b/src/drivers/MysqlDriver.ts @@ -91,8 +91,8 @@ export class MysqlDriver extends AbstractDriver { : null; break; case "tinyint": - if (resp.column_type == 'tinyint(1)') { - colInfo.char_max_lenght = 1 + if (resp.column_type == "tinyint(1)") { + colInfo.char_max_lenght = 1; colInfo.ts_type = "boolean"; } else { colInfo.char_max_lenght = @@ -232,7 +232,11 @@ export class MysqlDriver extends AbstractDriver { break; default: TomgUtils.LogFatalError( - `Unknown column type: ${resp.DATA_TYPE} table name: ${resp.TABLE_NAME} column name: ${resp.COLUMN_NAME}` + `Unknown column type: ${ + resp.DATA_TYPE + } table name: ${ + resp.TABLE_NAME + } column name: ${resp.COLUMN_NAME}` ); break; } @@ -345,7 +349,7 @@ export class MysqlDriver extends AbstractDriver { if (!ownerEntity) { TomgUtils.LogFatalError( `Relation between tables ${relationTmp.ownerTable} and ${ - relationTmp.referencedTable + relationTmp.referencedTable } didn't found entity model ${relationTmp.ownerTable}.` ); return; @@ -356,7 +360,7 @@ export class MysqlDriver extends AbstractDriver { if (!referencedEntity) { TomgUtils.LogFatalError( `Relation between tables ${relationTmp.ownerTable} and ${ - relationTmp.referencedTable + relationTmp.referencedTable } didn't found entity model ${relationTmp.referencedTable}.` ); return; @@ -367,9 +371,9 @@ export class MysqlDriver extends AbstractDriver { if (!ownerColumn) { TomgUtils.LogFatalError( `Relation between tables ${relationTmp.ownerTable} and ${ - relationTmp.referencedTable + relationTmp.referencedTable } didn't found entity column ${ - relationTmp.ownerTable + relationTmp.ownerTable }.${ownerColumn}.` ); return; @@ -380,9 +384,9 @@ export class MysqlDriver extends AbstractDriver { if (!relatedColumn) { TomgUtils.LogFatalError( `Relation between tables ${relationTmp.ownerTable} and ${ - relationTmp.referencedTable + relationTmp.referencedTable } didn't found entity column ${ - relationTmp.referencedTable + relationTmp.referencedTable }.${relatedColumn}.` ); return; diff --git a/src/drivers/PostgresDriver.ts b/src/drivers/PostgresDriver.ts index 204bb3e..ccef3ad 100644 --- a/src/drivers/PostgresDriver.ts +++ b/src/drivers/PostgresDriver.ts @@ -44,7 +44,7 @@ export class PostgresDriver extends AbstractDriver { response.forEach(val => { let ent: EntityInfo = new EntityInfo(); ent.EntityName = val.table_name; - ent.Schema=val.table_schema; + ent.Schema = val.table_schema; ent.Columns = []; ent.Indexes = []; ret.push(ent); @@ -87,7 +87,7 @@ export class PostgresDriver extends AbstractDriver { colInfo.default = colInfo.is_generated ? null : resp.column_default; - colInfo.sql_type = resp.data_type; + colInfo.sql_type = resp.data_type; switch (resp.data_type) { case "integer": colInfo.ts_type = "number"; @@ -210,7 +210,11 @@ export class PostgresDriver extends AbstractDriver { break; default: TomgUtils.LogFatalError( - `Unknown column type: ${resp.data_type} table name: ${resp.table_name} column name: ${resp.column_name}` + `Unknown column type: ${ + resp.data_type + } table name: ${ + resp.table_name + } column name: ${resp.column_name}` ); break; } diff --git a/src/models/EntityInfo.ts b/src/models/EntityInfo.ts index 357f4a8..ad016f7 100644 --- a/src/models/EntityInfo.ts +++ b/src/models/EntityInfo.ts @@ -10,7 +10,7 @@ export class EntityInfo { Imports: string[]; UniqueImports: string[]; Indexes: IndexInfo[]; - Schema:string; + Schema: string; relationImports(): any { var returnString = "";