parent
b81b54f57f
commit
ecd90e8ac8
@ -7,4 +7,5 @@ export class IConnectionOptions {
|
||||
public databaseType: string = "";
|
||||
public schemaName: string = "";
|
||||
public ssl: boolean = false;
|
||||
public timeout?: number;
|
||||
}
|
||||
|
@ -405,6 +405,7 @@ order by
|
||||
},
|
||||
password: connectionOptons.password,
|
||||
port: connectionOptons.port,
|
||||
requestTimeout: connectionOptons.timeout,
|
||||
server: connectionOptons.host,
|
||||
user: connectionOptons.user
|
||||
};
|
||||
|
@ -377,6 +377,7 @@ export class MysqlDriver extends AbstractDriver {
|
||||
ssl: {
|
||||
rejectUnauthorized: false
|
||||
},
|
||||
timeout: connectionOptons.timeout,
|
||||
user: connectionOptons.user
|
||||
};
|
||||
} else {
|
||||
@ -385,6 +386,7 @@ export class MysqlDriver extends AbstractDriver {
|
||||
host: connectionOptons.host,
|
||||
password: connectionOptons.password,
|
||||
port: connectionOptons.port,
|
||||
timeout: connectionOptons.timeout,
|
||||
user: connectionOptons.user
|
||||
};
|
||||
}
|
||||
|
@ -569,6 +569,7 @@ WHERE "n"."nspname" = table_schema AND "t"."typname"=udt_name
|
||||
password: connectionOptons.password,
|
||||
port: connectionOptons.port,
|
||||
ssl: connectionOptons.ssl,
|
||||
statement_timeout: connectionOptons.timeout,
|
||||
user: connectionOptons.user
|
||||
});
|
||||
|
||||
|
39
src/index.ts
39
src/index.ts
@ -161,6 +161,10 @@ function GetUtilParametersByArgs() {
|
||||
boolean: true,
|
||||
default: false,
|
||||
describe: "Generate constructor allowing partial initialization"
|
||||
})
|
||||
.option("timeout", {
|
||||
describe: "SQL Query timeout(ms)",
|
||||
number: true
|
||||
}).argv;
|
||||
|
||||
const driver = createDriver(argv.e);
|
||||
@ -184,6 +188,7 @@ function GetUtilParametersByArgs() {
|
||||
? argv.s.toString()
|
||||
: standardSchema),
|
||||
(connectionOptions.ssl = argv.ssl),
|
||||
(connectionOptions.timeout = argv.timeout),
|
||||
(connectionOptions.user = argv.u ? argv.u.toString() : standardUser);
|
||||
const generationOptions: IGenerationOptions = new IGenerationOptions();
|
||||
(generationOptions.activeRecord = argv.a),
|
||||
@ -306,15 +311,41 @@ async function GetUtilParametersByInquirer() {
|
||||
type: "input"
|
||||
}
|
||||
])) as any).output;
|
||||
const customize = ((await inquirer.prompt([
|
||||
|
||||
if (
|
||||
connectionOptions.databaseType === "mssql" ||
|
||||
connectionOptions.databaseType === "postgres"
|
||||
) {
|
||||
const changeRequestTimeout = ((await inquirer.prompt([
|
||||
{
|
||||
default: false,
|
||||
message: "Do you want to change default sql query timeout?",
|
||||
name: "changeRequestTimeout",
|
||||
type: "confirm"
|
||||
}
|
||||
])) as any).changeRequestTimeout;
|
||||
if (changeRequestTimeout) {
|
||||
const timeout: any = ((await inquirer.prompt({
|
||||
message: "Query timeout(ms):",
|
||||
name: "timeout",
|
||||
type: "input",
|
||||
validate(value) {
|
||||
const valid = !isNaN(parseInt(value, 10));
|
||||
return valid || "Please enter a valid number";
|
||||
}
|
||||
})) as any).timeout;
|
||||
connectionOptions.timeout = timeout;
|
||||
}
|
||||
}
|
||||
const customizeGeneration = ((await inquirer.prompt([
|
||||
{
|
||||
default: false,
|
||||
message: "Do you want to customize generated model?",
|
||||
name: "customize",
|
||||
name: "customizeGeneration",
|
||||
type: "confirm"
|
||||
}
|
||||
])) as any).customize;
|
||||
if (customize) {
|
||||
])) as any).customizeGeneration;
|
||||
if (customizeGeneration) {
|
||||
const customizations: string[] = ((await inquirer.prompt([
|
||||
{
|
||||
choices: [
|
||||
|
Loading…
Reference in New Issue
Block a user