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

@@ -21,6 +21,7 @@ import {
getTableSchema,
prepareItem,
replaceEmptyStringsByNulls,
configureTableSchemaUpdater,
} from '../../helpers/utils';
import { optionsCollection } from '../common.descriptions';
@@ -197,19 +198,31 @@ export async function execute(
db: PgpDatabase,
): Promise<INodeExecutionData[]> {
items = replaceEmptyStringsByNulls(items, nodeOptions.replaceEmptyStrings as boolean);
const nodeVersion = nodeOptions.typeVersion as number;
let schema = this.getNodeParameter('schema', 0, undefined, {
extractValue: true,
}) as string;
let table = this.getNodeParameter('table', 0, undefined, {
extractValue: true,
}) as string;
const updateTableSchema = configureTableSchemaUpdater(schema, table);
let tableSchema = await getTableSchema(db, schema, table);
const queries: QueryWithValues[] = [];
for (let i = 0; i < items.length; i++) {
const schema = this.getNodeParameter('schema', i, undefined, {
schema = this.getNodeParameter('schema', i, undefined, {
extractValue: true,
}) as string;
const table = this.getNodeParameter('table', i, undefined, {
table = this.getNodeParameter('table', i, undefined, {
extractValue: true,
}) as string;
const nodeVersion = this.getNode().typeVersion;
const columnsToMatchOn: string[] =
nodeVersion < 2.2
? [this.getNodeParameter('columnToMatchOn', i) as string]
@@ -255,7 +268,7 @@ export async function execute(
);
}
const tableSchema = await getTableSchema(db, schema, table);
tableSchema = await updateTableSchema(db, tableSchema, schema, table);
item = checkItemAgainstSchema(this.getNode(), item, tableSchema, i);