formatting
This commit is contained in:
parent
87ea4df1ec
commit
0530e1357b
@ -99,21 +99,31 @@ export abstract class AbstractDriver {
|
||||
});
|
||||
|
||||
let column1 = new ColumnInfo();
|
||||
column1.tsName = this.namingStrategy.entityName(namesOfRelatedTables[1]);
|
||||
column1.tsName = this.namingStrategy.entityName(
|
||||
namesOfRelatedTables[1]
|
||||
);
|
||||
let col1Rel = new RelationInfo();
|
||||
col1Rel.relatedTable = namesOfRelatedTables[1];
|
||||
col1Rel.relatedColumn = this.namingStrategy.entityName(namesOfRelatedTables[1]);
|
||||
col1Rel.relatedColumn = this.namingStrategy.entityName(
|
||||
namesOfRelatedTables[1]
|
||||
);
|
||||
col1Rel.relationType = "ManyToMany";
|
||||
col1Rel.isOwner = true;
|
||||
col1Rel.ownerColumn = this.namingStrategy.entityName(namesOfRelatedTables[0]);
|
||||
col1Rel.ownerColumn = this.namingStrategy.entityName(
|
||||
namesOfRelatedTables[0]
|
||||
);
|
||||
column1.relations.push(col1Rel);
|
||||
relatedTable1.Columns.push(column1);
|
||||
|
||||
let column2 = new ColumnInfo();
|
||||
column2.tsName = this.namingStrategy.entityName(namesOfRelatedTables[0]);
|
||||
column2.tsName = this.namingStrategy.entityName(
|
||||
namesOfRelatedTables[0]
|
||||
);
|
||||
let col2Rel = new RelationInfo();
|
||||
col2Rel.relatedTable = namesOfRelatedTables[0];
|
||||
col2Rel.relatedColumn = this.namingStrategy.entityName(namesOfRelatedTables[1]);
|
||||
col2Rel.relatedColumn = this.namingStrategy.entityName(
|
||||
namesOfRelatedTables[1]
|
||||
);
|
||||
col2Rel.relationType = "ManyToMany";
|
||||
col2Rel.isOwner = false;
|
||||
column2.relations.push(col2Rel);
|
||||
@ -129,7 +139,7 @@ export abstract class AbstractDriver {
|
||||
password: string,
|
||||
schema: string,
|
||||
ssl: boolean,
|
||||
namingStrategy:NamingStrategy
|
||||
namingStrategy: NamingStrategy
|
||||
): Promise<DatabaseModel> {
|
||||
let dbModel = <DatabaseModel>{};
|
||||
this.namingStrategy = namingStrategy;
|
||||
@ -267,10 +277,14 @@ export abstract class AbstractDriver {
|
||||
ownerRelation.relatedTable = relationTmp.referencedTable;
|
||||
ownerRelation.ownerTable = relationTmp.ownerTable;
|
||||
ownerRelation.relationType = isOneToMany
|
||||
? "ManyToOne"
|
||||
? "ManyToOne"
|
||||
: "OneToOne";
|
||||
|
||||
let columnName = this.namingStrategy.relationName(ownerEntity,referencedEntity,isOneToMany);
|
||||
let columnName = this.namingStrategy.relationName(
|
||||
ownerEntity,
|
||||
referencedEntity,
|
||||
isOneToMany
|
||||
);
|
||||
ownerRelation.ownerColumn = columnName;
|
||||
ownerColumn.relations.push(ownerRelation);
|
||||
if (isOneToMany) {
|
||||
@ -329,7 +343,9 @@ export abstract class AbstractDriver {
|
||||
entity.Columns.forEach(col => {
|
||||
if (
|
||||
primaryIndex &&
|
||||
primaryIndex.columns.some(cIndex => cIndex.name == col.tsName)
|
||||
primaryIndex.columns.some(
|
||||
cIndex => cIndex.name == col.tsName
|
||||
)
|
||||
)
|
||||
col.isPrimary = true;
|
||||
});
|
||||
|
@ -53,7 +53,9 @@ export class MssqlDriver extends AbstractDriver {
|
||||
})
|
||||
.forEach(resp => {
|
||||
let colInfo: ColumnInfo = new ColumnInfo();
|
||||
colInfo.tsName = this.namingStrategy.entityName(resp.COLUMN_NAME);
|
||||
colInfo.tsName = this.namingStrategy.entityName(
|
||||
resp.COLUMN_NAME
|
||||
);
|
||||
colInfo.sqlName = resp.COLUMN_NAME;
|
||||
colInfo.is_nullable = resp.IS_NULLABLE == "YES";
|
||||
colInfo.is_generated = resp.IsIdentity == 1;
|
||||
|
@ -45,7 +45,9 @@ export class MysqlDriver extends AbstractDriver {
|
||||
})
|
||||
.forEach(resp => {
|
||||
let colInfo: ColumnInfo = new ColumnInfo();
|
||||
colInfo.tsName = this.namingStrategy.entityName(resp.COLUMN_NAME);
|
||||
colInfo.tsName = this.namingStrategy.entityName(
|
||||
resp.COLUMN_NAME
|
||||
);
|
||||
colInfo.sqlName = resp.COLUMN_NAME;
|
||||
colInfo.is_nullable = resp.IS_NULLABLE == "YES";
|
||||
colInfo.is_generated = resp.IsIdentity == 1;
|
||||
|
@ -55,7 +55,9 @@ export class OracleDriver extends AbstractDriver {
|
||||
})
|
||||
.forEach(resp => {
|
||||
let colInfo: ColumnInfo = new ColumnInfo();
|
||||
colInfo.tsName = this.namingStrategy.entityName(resp.COLUMN_NAME);
|
||||
colInfo.tsName = this.namingStrategy.entityName(
|
||||
resp.COLUMN_NAME
|
||||
);
|
||||
colInfo.sqlName = resp.COLUMN_NAME;
|
||||
colInfo.is_nullable = resp.NULLABLE == "Y";
|
||||
colInfo.is_generated = resp.IDENTITY_COLUMN == "YES";
|
||||
|
@ -54,7 +54,9 @@ export class PostgresDriver extends AbstractDriver {
|
||||
})
|
||||
.forEach(resp => {
|
||||
let colInfo: ColumnInfo = new ColumnInfo();
|
||||
colInfo.tsName = this.namingStrategy.entityName(resp.column_name);
|
||||
colInfo.tsName = this.namingStrategy.entityName(
|
||||
resp.column_name
|
||||
);
|
||||
colInfo.sqlName = resp.column_name;
|
||||
colInfo.is_nullable = resp.is_nullable == "YES";
|
||||
colInfo.is_generated = resp.isidentity == "YES";
|
||||
|
@ -153,16 +153,12 @@ export class SqliteDriver extends AbstractDriver {
|
||||
) &&
|
||||
options
|
||||
) {
|
||||
colInfo.numericPrecision = <any>(
|
||||
options[0]
|
||||
.substring(1, options[0].length - 1)
|
||||
.split(",")[0]
|
||||
);
|
||||
colInfo.numericScale = <any>(
|
||||
options[0]
|
||||
.substring(1, options[0].length - 1)
|
||||
.split(",")[1]
|
||||
);
|
||||
colInfo.numericPrecision = <any>options[0]
|
||||
.substring(1, options[0].length - 1)
|
||||
.split(",")[0];
|
||||
colInfo.numericScale = <any>options[0]
|
||||
.substring(1, options[0].length - 1)
|
||||
.split(",")[1];
|
||||
}
|
||||
if (
|
||||
this.ColumnTypesWithLength.some(
|
||||
@ -170,8 +166,9 @@ export class SqliteDriver extends AbstractDriver {
|
||||
) &&
|
||||
options
|
||||
) {
|
||||
colInfo.lenght = <any>(
|
||||
options[0].substring(1, options[0].length - 1)
|
||||
colInfo.lenght = <any>options[0].substring(
|
||||
1,
|
||||
options[0].length - 1
|
||||
);
|
||||
}
|
||||
if (
|
||||
@ -182,8 +179,9 @@ export class SqliteDriver extends AbstractDriver {
|
||||
) &&
|
||||
options
|
||||
) {
|
||||
colInfo.width = <any>(
|
||||
options[0].substring(1, options[0].length - 1)
|
||||
colInfo.width = <any>options[0].substring(
|
||||
1,
|
||||
options[0].length - 1
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user