mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-20 11:22:15 +00:00
fix(Google Sheets Node): Check for column names changes before upsert, append, update (#9649)
This commit is contained in:
@@ -5,6 +5,7 @@ import type {
|
||||
INodeListSearchItems,
|
||||
INodePropertyOptions,
|
||||
INode,
|
||||
ResourceMapperField,
|
||||
} from 'n8n-workflow';
|
||||
import { NodeOperationError } from 'n8n-workflow';
|
||||
import type { GoogleSheet } from './GoogleSheet';
|
||||
@@ -334,3 +335,25 @@ export function cellFormatDefault(nodeVersion: number) {
|
||||
}
|
||||
return 'USER_ENTERED';
|
||||
}
|
||||
|
||||
export function checkForSchemaChanges(
|
||||
node: INode,
|
||||
columnNames: string[],
|
||||
schema: ResourceMapperField[],
|
||||
) {
|
||||
const updatedColumnNames: Array<{ oldName: string; newName: string }> = [];
|
||||
|
||||
for (const [columnIndex, columnName] of columnNames.entries()) {
|
||||
const schemaEntry = schema[columnIndex];
|
||||
if (schemaEntry === undefined) break;
|
||||
if (columnName !== schema[columnIndex].id) {
|
||||
updatedColumnNames.push({ oldName: schema[columnIndex].id, newName: columnName });
|
||||
}
|
||||
}
|
||||
|
||||
if (updatedColumnNames.length) {
|
||||
throw new NodeOperationError(node, "Column names were updated after the node's setup", {
|
||||
description: `Refresh the columns list in the 'Column to Match On' parameter. Updated columns: ${updatedColumnNames.map((c) => `${c.oldName} -> ${c.newName}`).join(', ')}`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user