mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
⚡ Add Schema to Postgres-Update #996
This commit is contained in:
@@ -105,11 +105,14 @@ export async function pgUpdate(
|
||||
items: INodeExecutionData[],
|
||||
): Promise<IDataObject[]> {
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user