diff --git a/packages/nodes-base/nodes/Postgres/Postgres.node.functions.ts b/packages/nodes-base/nodes/Postgres/Postgres.node.functions.ts index 0e7f738277..eaeebe313e 100644 --- a/packages/nodes-base/nodes/Postgres/Postgres.node.functions.ts +++ b/packages/nodes-base/nodes/Postgres/Postgres.node.functions.ts @@ -105,11 +105,14 @@ export async function pgUpdate( items: INodeExecutionData[], ): Promise { const table = getNodeParam('table', 0) as string; + const schema = getNodeParam('schema', 0) as string; const updateKey = getNodeParam('updateKey', 0) as string; const columnString = getNodeParam('columns', 0) as string; const columns = columnString.split(',').map(column => column.trim()); + const te = new pgp.helpers.TableName({ table, schema }); + // Make sure that the updateKey does also get queried if (!columns.includes(updateKey)) { columns.unshift(updateKey); @@ -120,7 +123,7 @@ export async function pgUpdate( // Generate the multi-row update query const query = - pgp.helpers.update(updateItems, columns, table) + ' WHERE v.' + updateKey + ' = t.' + updateKey; + pgp.helpers.update(updateItems, columns, te) + ' WHERE v.' + updateKey + ' = t.' + updateKey; // Executing the query to update the data await db.none(query); diff --git a/packages/nodes-base/nodes/Postgres/Postgres.node.ts b/packages/nodes-base/nodes/Postgres/Postgres.node.ts index 7c706a0fc2..1628510841 100644 --- a/packages/nodes-base/nodes/Postgres/Postgres.node.ts +++ b/packages/nodes-base/nodes/Postgres/Postgres.node.ts @@ -136,6 +136,19 @@ export class Postgres implements INodeType { // ---------------------------------- // update // ---------------------------------- + { + displayName: 'Schema', + name: 'schema', + type: 'string', + displayOptions: { + show: { + operation: ['update'], + }, + }, + default: 'public', + required: true, + description: 'Name of the schema the table belongs to', + }, { displayName: 'Table', name: 'table',