mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 10:31:15 +00:00
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:
@@ -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));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user