change param name to skipSchema
This commit is contained in:
parent
fbf5980dce
commit
130be42f25
@ -143,10 +143,13 @@ function addImportsAndGenerationOptions(
|
||||
});
|
||||
element.GenerateConstructor = generationOptions.generateConstructor;
|
||||
element.IsActiveRecord = generationOptions.activeRecord;
|
||||
element.detached = generationOptions.detached;
|
||||
element.Imports.filter((elem, index, self) => {
|
||||
return index === self.indexOf(elem);
|
||||
});
|
||||
if (generationOptions.skipSchema) {
|
||||
element.Schema = undefined;
|
||||
element.Database = undefined;
|
||||
}
|
||||
});
|
||||
return dbModel;
|
||||
}
|
||||
|
@ -22,5 +22,5 @@ export default class IGenerationOptions {
|
||||
|
||||
public relationIds: boolean = false;
|
||||
|
||||
public detached: boolean = false;
|
||||
public skipSchema: boolean = false;
|
||||
}
|
||||
|
@ -221,9 +221,7 @@ export default abstract class AbstractDriver {
|
||||
);
|
||||
if (!ownerEntity) {
|
||||
TomgUtils.LogError(
|
||||
`Relation between tables ${relationTmp.ownerTable} and ${
|
||||
relationTmp.referencedTable
|
||||
} didn't found entity model ${relationTmp.ownerTable}.`
|
||||
`Relation between tables ${relationTmp.ownerTable} and ${relationTmp.referencedTable} didn't found entity model ${relationTmp.ownerTable}.`
|
||||
);
|
||||
return;
|
||||
}
|
||||
@ -233,9 +231,7 @@ export default abstract class AbstractDriver {
|
||||
);
|
||||
if (!referencedEntity) {
|
||||
TomgUtils.LogError(
|
||||
`Relation between tables ${relationTmp.ownerTable} and ${
|
||||
relationTmp.referencedTable
|
||||
} didn't found entity model ${relationTmp.referencedTable}.`
|
||||
`Relation between tables ${relationTmp.ownerTable} and ${relationTmp.referencedTable} didn't found entity model ${relationTmp.referencedTable}.`
|
||||
);
|
||||
return;
|
||||
}
|
||||
@ -251,13 +247,7 @@ export default abstract class AbstractDriver {
|
||||
);
|
||||
if (!ownerColumn) {
|
||||
TomgUtils.LogError(
|
||||
`Relation between tables ${
|
||||
relationTmp.ownerTable
|
||||
} and ${
|
||||
relationTmp.referencedTable
|
||||
} didn't found entity column ${
|
||||
relationTmp.ownerTable
|
||||
}.${ownerColumn}.`
|
||||
`Relation between tables ${relationTmp.ownerTable} and ${relationTmp.referencedTable} didn't found entity column ${relationTmp.ownerTable}.${ownerColumn}.`
|
||||
);
|
||||
return;
|
||||
}
|
||||
@ -268,13 +258,7 @@ export default abstract class AbstractDriver {
|
||||
);
|
||||
if (!relatedColumn) {
|
||||
TomgUtils.LogError(
|
||||
`Relation between tables ${
|
||||
relationTmp.ownerTable
|
||||
} and ${
|
||||
relationTmp.referencedTable
|
||||
} didn't found entity column ${
|
||||
relationTmp.referencedTable
|
||||
}.${relatedColumn}.`
|
||||
`Relation between tables ${relationTmp.ownerTable} and ${relationTmp.referencedTable} didn't found entity column ${relationTmp.referencedTable}.${relatedColumn}.`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
@ -191,11 +191,7 @@ WHERE TABLE_TYPE='BASE TABLE' and TABLE_SCHEMA in (${schema}) AND TABLE_CATALOG
|
||||
break;
|
||||
default:
|
||||
TomgUtils.LogError(
|
||||
`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;
|
||||
}
|
||||
|
@ -208,11 +208,7 @@ export default class MysqlDriver extends AbstractDriver {
|
||||
break;
|
||||
default:
|
||||
TomgUtils.LogError(
|
||||
`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;
|
||||
}
|
||||
|
@ -309,9 +309,7 @@ export default class OracleDriver extends AbstractDriver {
|
||||
let config: any;
|
||||
if (connectionOptons.user === String(process.env.ORACLE_UsernameSys)) {
|
||||
config /* Oracle.IConnectionAttributes */ = {
|
||||
connectString: `${connectionOptons.host}:${
|
||||
connectionOptons.port
|
||||
}/${connectionOptons.databaseName}`,
|
||||
connectString: `${connectionOptons.host}:${connectionOptons.port}/${connectionOptons.databaseName}`,
|
||||
externalAuth: connectionOptons.ssl,
|
||||
password: connectionOptons.password,
|
||||
privilege: this.Oracle.SYSDBA,
|
||||
@ -319,9 +317,7 @@ export default class OracleDriver extends AbstractDriver {
|
||||
};
|
||||
} else {
|
||||
config /* Oracle.IConnectionAttributes */ = {
|
||||
connectString: `${connectionOptons.host}:${
|
||||
connectionOptons.port
|
||||
}/${connectionOptons.databaseName}`,
|
||||
connectString: `${connectionOptons.host}:${connectionOptons.port}/${connectionOptons.databaseName}`,
|
||||
externalAuth: connectionOptons.ssl,
|
||||
password: connectionOptons.password,
|
||||
user: connectionOptons.user
|
||||
|
@ -102,19 +102,11 @@ WHERE "n"."nspname" = table_schema AND "t"."typname"=udt_name
|
||||
resp.data_type === "ARRAY"
|
||||
) {
|
||||
TomgUtils.LogError(
|
||||
`Unknown ${resp.data_type} column type: ${
|
||||
resp.udt_name
|
||||
} table name: ${
|
||||
resp.table_name
|
||||
} column name: ${resp.column_name}`
|
||||
`Unknown ${resp.data_type} column type: ${resp.udt_name} table name: ${resp.table_name} column name: ${resp.column_name}`
|
||||
);
|
||||
} else {
|
||||
TomgUtils.LogError(
|
||||
`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}`
|
||||
);
|
||||
}
|
||||
return;
|
||||
|
@ -163,11 +163,7 @@ export default class SqliteDriver extends AbstractDriver {
|
||||
break;
|
||||
default:
|
||||
TomgUtils.LogError(
|
||||
`Unknown column type: ${
|
||||
colInfo.options.type
|
||||
} table name: ${
|
||||
ent.tsEntityName
|
||||
} column name: ${resp.name}`
|
||||
`Unknown column type: ${colInfo.options.type} table name: ${ent.tsEntityName} column name: ${resp.name}`
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ import {BaseEntity,Column,Entity,Index,JoinColumn,JoinTable,ManyToMany,ManyToOne
|
||||
{{/each}}
|
||||
|
||||
|
||||
@Entity("{{sqlEntityName}}"{{#unless detached}}{{#Schema}} ,{schema:"{{.}}"{{#if ../Database}}, database:"{{../Database}}"{{/if}} } {{/Schema}}{{/unless}})
|
||||
@Entity("{{sqlEntityName}}"{{#Schema}} ,{schema:"{{.}}"{{#if ../Database}}, database:"{{../Database}}"{{/if}} } {{/Schema}})
|
||||
{{#Indexes}}{{^isPrimaryKey}}@Index("{{name}}",[{{#columns}}"{{toPropertyName name}}",{{/columns}}]{{#isUnique}},{unique:true}{{/isUnique}})
|
||||
{{/isPrimaryKey}}{{/Indexes}}export class {{toEntityName tsEntityName}}{{#IsActiveRecord}} extends BaseEntity{{/IsActiveRecord}} {
|
||||
{{#Columns}}
|
||||
|
14
src/index.ts
14
src/index.ts
@ -153,11 +153,10 @@ function GetUtilParametersByArgs() {
|
||||
default: false,
|
||||
describe: "Generate RelationId fields"
|
||||
})
|
||||
.option("detached", {
|
||||
.option("skipSchema", {
|
||||
boolean: true,
|
||||
default: false,
|
||||
describe:
|
||||
"If set, omits database and schema identifier in generated entities"
|
||||
describe: "Omits schema identifier in generated entities"
|
||||
})
|
||||
.option("generateConstructor", {
|
||||
boolean: true,
|
||||
@ -200,7 +199,7 @@ function GetUtilParametersByArgs() {
|
||||
generationOptions.noConfigs = argv.noConfig;
|
||||
generationOptions.propertyVisibility = argv.pv;
|
||||
generationOptions.relationIds = argv.relationIds;
|
||||
generationOptions.detached = argv.detached;
|
||||
generationOptions.skipSchema = argv.skipSchema;
|
||||
generationOptions.resultsPath = argv.o ? argv.o.toString() : null;
|
||||
return { driver, connectionOptions, generationOptions };
|
||||
}
|
||||
@ -370,9 +369,8 @@ async function GetUtilParametersByInquirer() {
|
||||
value: "relationId"
|
||||
},
|
||||
{
|
||||
name:
|
||||
"Omit schema qualifier, allowing you to switch it at runtime",
|
||||
value: "detached"
|
||||
name: "Omits schema identifier in generated entities",
|
||||
value: "skipSchema"
|
||||
},
|
||||
{
|
||||
name:
|
||||
@ -407,7 +405,7 @@ async function GetUtilParametersByInquirer() {
|
||||
"activeRecord"
|
||||
);
|
||||
generationOptions.relationIds = customizations.includes("relationId");
|
||||
generationOptions.detached = customizations.includes("detached");
|
||||
generationOptions.skipSchema = customizations.includes("skipSchema");
|
||||
generationOptions.generateConstructor = customizations.includes(
|
||||
"constructor"
|
||||
);
|
||||
|
@ -14,15 +14,13 @@ export default class EntityInfo {
|
||||
|
||||
public Indexes: IndexInfo[];
|
||||
|
||||
public Schema: string;
|
||||
public Schema?: string;
|
||||
|
||||
public GenerateConstructor: boolean;
|
||||
|
||||
public detached: boolean;
|
||||
|
||||
public IsActiveRecord: boolean;
|
||||
|
||||
public Database: string;
|
||||
public Database?: string;
|
||||
|
||||
public relationImports() {
|
||||
const imports: string[] = [];
|
||||
|
@ -23,7 +23,7 @@ export function getGenerationOptions(resultsPath: string): IGenerationOptions {
|
||||
generateConstructor: false,
|
||||
customNamingStrategyPath: "",
|
||||
relationIds: false,
|
||||
detached: false,
|
||||
skipSchema: false,
|
||||
activeRecord: false
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user