mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
fix(Postgres Node): Re-use connection pool across executions (#12346)
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
@@ -9,18 +9,14 @@ export async function schemaSearch(this: ILoadOptionsFunctions): Promise<INodeLi
|
||||
|
||||
const { db } = await configurePostgres.call(this, credentials, options);
|
||||
|
||||
try {
|
||||
const response = await db.any('SELECT schema_name FROM information_schema.schemata');
|
||||
const response = await db.any('SELECT schema_name FROM information_schema.schemata');
|
||||
|
||||
return {
|
||||
results: response.map((schema) => ({
|
||||
name: schema.schema_name as string,
|
||||
value: schema.schema_name as string,
|
||||
})),
|
||||
};
|
||||
} finally {
|
||||
if (!db.$pool.ending) await db.$pool.end();
|
||||
}
|
||||
return {
|
||||
results: response.map((schema) => ({
|
||||
name: schema.schema_name as string,
|
||||
value: schema.schema_name as string,
|
||||
})),
|
||||
};
|
||||
}
|
||||
export async function tableSearch(this: ILoadOptionsFunctions): Promise<INodeListSearchResult> {
|
||||
const credentials = await this.getCredentials<PostgresNodeCredentials>('postgres');
|
||||
@@ -32,19 +28,15 @@ export async function tableSearch(this: ILoadOptionsFunctions): Promise<INodeLis
|
||||
extractValue: true,
|
||||
}) as string;
|
||||
|
||||
try {
|
||||
const response = await db.any(
|
||||
'SELECT table_name FROM information_schema.tables WHERE table_schema=$1',
|
||||
[schema],
|
||||
);
|
||||
const response = await db.any(
|
||||
'SELECT table_name FROM information_schema.tables WHERE table_schema=$1',
|
||||
[schema],
|
||||
);
|
||||
|
||||
return {
|
||||
results: response.map((table) => ({
|
||||
name: table.table_name as string,
|
||||
value: table.table_name as string,
|
||||
})),
|
||||
};
|
||||
} finally {
|
||||
if (!db.$pool.ending) await db.$pool.end();
|
||||
}
|
||||
return {
|
||||
results: response.map((table) => ({
|
||||
name: table.table_name as string,
|
||||
value: table.table_name as string,
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user