fix(Postgres Node): Remove reusable connections (no-changelog) (#6259)

This commit is contained in:
Michael Kret
2023-05-19 16:42:24 +03:00
committed by GitHub
parent 4b5cbe7750
commit be5d3264ad
7 changed files with 64 additions and 61 deletions

View File

@@ -1,13 +1,13 @@
import type { ILoadOptionsFunctions, INodePropertyOptions } from 'n8n-workflow';
import type { ConnectionsData } from '../helpers/interfaces';
import { getTableSchema } from '../helpers/utils';
import { Connections } from '../transport';
import { configurePostgres } from '../transport';
export async function getColumns(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const credentials = await this.getCredentials('postgres');
const options = { nodeVersion: this.getNode().typeVersion };
const { db } = (await Connections.getInstance(credentials, options)) as ConnectionsData;
const { db, pgp, sshClient } = await configurePostgres(credentials, options);
const schema = this.getNodeParameter('schema', 0, {
extractValue: true,
@@ -27,6 +27,11 @@ export async function getColumns(this: ILoadOptionsFunctions): Promise<INodeProp
}));
} catch (error) {
throw error;
} finally {
if (sshClient) {
sshClient.end();
}
pgp.end();
}
}