fix(Postgres Node): Connection pool of the database object has been destroyed (#7074)

Github issue / Community forum post (link here to close automatically):
This commit is contained in:
Michael Kret
2023-09-01 22:19:10 +03:00
committed by GitHub
parent 008cdcce56
commit 9dd5f0e579
10 changed files with 83 additions and 27 deletions

View File

@@ -6,7 +6,7 @@ export async function schemaSearch(this: ILoadOptionsFunctions): Promise<INodeLi
const credentials = await this.getCredentials('postgres');
const options = { nodeVersion: this.getNode().typeVersion };
const { db, pgp, sshClient } = await configurePostgres(credentials, options);
const { db, sshClient } = await configurePostgres(credentials, options);
try {
const response = await db.any('SELECT schema_name FROM information_schema.schemata');
@@ -23,14 +23,14 @@ export async function schemaSearch(this: ILoadOptionsFunctions): Promise<INodeLi
if (sshClient) {
sshClient.end();
}
pgp.end();
await db.$pool.end();
}
}
export async function tableSearch(this: ILoadOptionsFunctions): Promise<INodeListSearchResult> {
const credentials = await this.getCredentials('postgres');
const options = { nodeVersion: this.getNode().typeVersion };
const { db, pgp, sshClient } = await configurePostgres(credentials, options);
const { db, sshClient } = await configurePostgres(credentials, options);
const schema = this.getNodeParameter('schema', 0, {
extractValue: true,
@@ -54,6 +54,6 @@ export async function tableSearch(this: ILoadOptionsFunctions): Promise<INodeLis
if (sshClient) {
sshClient.end();
}
pgp.end();
await db.$pool.end();
}
}

View File

@@ -7,7 +7,7 @@ export async function getColumns(this: ILoadOptionsFunctions): Promise<INodeProp
const credentials = await this.getCredentials('postgres');
const options = { nodeVersion: this.getNode().typeVersion };
const { db, pgp, sshClient } = await configurePostgres(credentials, options);
const { db, sshClient } = await configurePostgres(credentials, options);
const schema = this.getNodeParameter('schema', 0, {
extractValue: true,
@@ -31,7 +31,7 @@ export async function getColumns(this: ILoadOptionsFunctions): Promise<INodeProp
if (sshClient) {
sshClient.end();
}
pgp.end();
await db.$pool.end();
}
}

View File

@@ -70,7 +70,8 @@ export async function getMappingColumns(
const canBeUsedToMatch =
operation === 'upsert' ? unique.some((u) => u.attname === col.column_name) : true;
const type = mapPostgresType(col.data_type);
const options = type === 'options' ? getEnumValues(enumInfo, col.udt_name) : undefined;
const options =
type === 'options' ? getEnumValues(enumInfo, col.udt_name as string) : undefined;
const isAutoIncrement = col.column_default?.startsWith('nextval');
return {
id: col.column_name,