Browse Source

refactor(nocodb): move to addTypeCastConfig

pull/5601/head
Wing-Kam Wong 2 years ago
parent
commit
97948a46b4
  1. 40
      packages/nocodb-nest/src/utils/NcConfigFactory.ts

40
packages/nocodb-nest/src/utils/NcConfigFactory.ts

@ -236,12 +236,10 @@ export default class NcConfigFactory {
acquireConnectionTimeout: 600000, acquireConnectionTimeout: 600000,
} as any; } as any;
if (url.protocol.startsWith('mysql')) { dbConfig.connection = this.addTypeCastConfig(
dbConfig.connection = { url.protocol,
...dbConfig.connection, dbConfig.connection,
...this.mysqlConnectionTypeCastConfig, );
};
}
if (process.env.NODE_TLS_REJECT_UNAUTHORIZED) { if (process.env.NODE_TLS_REJECT_UNAUTHORIZED) {
dbConfig.connection.ssl = true; dbConfig.connection.ssl = true;
@ -304,6 +302,16 @@ export default class NcConfigFactory {
.replace(/[ -]/g, '_');*/ .replace(/[ -]/g, '_');*/
} }
private static addTypeCastConfig(clientType: string, connection) {
if (clientType.startsWith('mysql')) {
connection = {
...connection,
...this.mysqlConnectionTypeCastConfig,
};
}
return connection;
}
static async metaUrlToDbConfig(urlString) { static async metaUrlToDbConfig(urlString) {
const url = new URL(urlString); const url = new URL(urlString);
@ -356,12 +364,10 @@ export default class NcConfigFactory {
: {}), : {}),
}; };
if (url.protocol.startsWith('mysql')) { dbConfig.connection = this.addTypeCastConfig(
dbConfig.connection = { url.protocol,
...dbConfig.connection, dbConfig.connection,
...this.mysqlConnectionTypeCastConfig, );
};
}
if (process.env.NODE_TLS_REJECT_UNAUTHORIZED) { if (process.env.NODE_TLS_REJECT_UNAUTHORIZED) {
dbConfig.connection.ssl = true; dbConfig.connection.ssl = true;
@ -526,12 +532,10 @@ export default class NcConfigFactory {
}; };
} }
if (dbConfig.client.startsWith('mysql')) { dbConfig.connection = this.addTypeCastConfig(
dbConfig.connection = { dbConfig.client,
...dbConfig.connection, dbConfig.connection,
...this.mysqlConnectionTypeCastConfig, );
};
}
// todo: // todo:
const key = ''; const key = '';

Loading…
Cancel
Save