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

@@ -17,6 +17,7 @@ import type {
import {
addReturning,
checkItemAgainstSchema,
configureTableSchemaUpdater,
getTableSchema,
prepareItem,
replaceEmptyStringsByNulls,
@@ -161,15 +162,28 @@ 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;
@@ -183,7 +197,6 @@ export async function execute(
let query = `INSERT INTO $1:name.$2:name($3:name) VALUES($3:csv)${onConflict}`;
let values: QueryValues = [schema, table];
const nodeVersion = this.getNode().typeVersion;
const dataMode =
nodeVersion < 2.2
? (this.getNodeParameter('dataMode', i) as string)
@@ -209,7 +222,7 @@ export async function execute(
}
}
const tableSchema = await getTableSchema(db, schema, table);
tableSchema = await updateTableSchema(db, tableSchema, schema, table);
values.push(checkItemAgainstSchema(this.getNode(), item, tableSchema, i));