mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-09 22:24:05 -08:00
fix(Google Sheets Node): Do not insert row_number as a new column, do not checkForSchemaChanges in update operation (#10201)
This commit is contained in:
parent
2eba57774b
commit
5136d10ca3
|
@ -5,11 +5,12 @@ import type {
|
|||
ResourceMapperField,
|
||||
} from 'n8n-workflow';
|
||||
import { NodeOperationError } from 'n8n-workflow';
|
||||
import type {
|
||||
ISheetUpdateData,
|
||||
SheetProperties,
|
||||
ValueInputOption,
|
||||
ValueRenderOption,
|
||||
import {
|
||||
ROW_NUMBER,
|
||||
type ISheetUpdateData,
|
||||
type SheetProperties,
|
||||
type ValueInputOption,
|
||||
type ValueRenderOption,
|
||||
} from '../../helpers/GoogleSheets.types';
|
||||
import type { GoogleSheet } from '../../helpers/GoogleSheet';
|
||||
import {
|
||||
|
@ -312,7 +313,7 @@ export async function execute(
|
|||
};
|
||||
|
||||
const addNewColumn = (key: string) => {
|
||||
if (!columnNames.includes(key)) {
|
||||
if (!columnNames.includes(key) && key !== ROW_NUMBER) {
|
||||
newColumns.add(key);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,22 +1,14 @@
|
|||
import type {
|
||||
IExecuteFunctions,
|
||||
IDataObject,
|
||||
INodeExecutionData,
|
||||
ResourceMapperField,
|
||||
} from 'n8n-workflow';
|
||||
import type { IExecuteFunctions, IDataObject, INodeExecutionData } from 'n8n-workflow';
|
||||
import { NodeOperationError } from 'n8n-workflow';
|
||||
import type {
|
||||
ISheetUpdateData,
|
||||
SheetProperties,
|
||||
ValueInputOption,
|
||||
ValueRenderOption,
|
||||
import {
|
||||
ROW_NUMBER,
|
||||
type ISheetUpdateData,
|
||||
type SheetProperties,
|
||||
type ValueInputOption,
|
||||
type ValueRenderOption,
|
||||
} from '../../helpers/GoogleSheets.types';
|
||||
import type { GoogleSheet } from '../../helpers/GoogleSheet';
|
||||
import {
|
||||
cellFormatDefault,
|
||||
checkForSchemaChanges,
|
||||
untilSheetSelected,
|
||||
} from '../../helpers/GoogleSheets.utils';
|
||||
import { cellFormatDefault, untilSheetSelected } from '../../helpers/GoogleSheets.utils';
|
||||
import { cellFormat, handlingExtraData, locationDefine } from './commonDescription';
|
||||
|
||||
export const description: SheetProperties = [
|
||||
|
@ -262,11 +254,6 @@ export async function execute(
|
|||
|
||||
columnNames = sheetData[keyRowIndex];
|
||||
|
||||
if (nodeVersion >= 4.4) {
|
||||
const schema = this.getNodeParameter('columns.schema', 0) as ResourceMapperField[];
|
||||
checkForSchemaChanges(this.getNode(), columnNames, schema);
|
||||
}
|
||||
|
||||
const newColumns = new Set<string>();
|
||||
|
||||
const columnsToMatchOn: string[] =
|
||||
|
@ -305,7 +292,7 @@ export async function execute(
|
|||
};
|
||||
|
||||
const addNewColumn = (key: string) => {
|
||||
if (!columnNames.includes(key)) {
|
||||
if (!columnNames.includes(key) && key !== ROW_NUMBER) {
|
||||
newColumns.add(key);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -343,11 +343,16 @@ export function checkForSchemaChanges(
|
|||
) {
|
||||
const updatedColumnNames: Array<{ oldName: string; newName: string }> = [];
|
||||
|
||||
//if sheet does not contain ROW_NUMBER ignore it as data come from read rows operation
|
||||
const schemaColumns = columnNames.includes(ROW_NUMBER)
|
||||
? schema.map((s) => s.id)
|
||||
: schema.filter((s) => s.id !== ROW_NUMBER).map((s) => s.id);
|
||||
|
||||
for (const [columnIndex, columnName] of columnNames.entries()) {
|
||||
const schemaEntry = schema[columnIndex];
|
||||
const schemaEntry = schemaColumns[columnIndex];
|
||||
if (schemaEntry === undefined) break;
|
||||
if (columnName !== schema[columnIndex].id) {
|
||||
updatedColumnNames.push({ oldName: schema[columnIndex].id, newName: columnName });
|
||||
if (columnName !== schemaEntry) {
|
||||
updatedColumnNames.push({ oldName: schemaEntry, newName: columnName });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue