Skip to content

Commit

Permalink
fix(Google Sheets Node): Better error when column to match on is empty (
Browse files Browse the repository at this point in the history
n8n-io#10442)

Co-authored-by: Shireen Missi <[email protected]>
  • Loading branch information
michael-radency and ShireenMissi authored Aug 16, 2024
1 parent 0d3ed46 commit ce46bf5
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ const fieldDescription = computed<string>(() => {
resourceMapperTypeOptions.value?.multiKeyMatch === true
? `${pluralFieldWord.value}`
: `${singularFieldWord.value}`,
nodeDisplayName: props.serviceName,
},
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,18 @@ describe('ResourceMapper.vue', () => {
},
{ merge: true },
);

await waitAllPromises();
expect(getByText('Set the value for each foo')).toBeInTheDocument();
expect(
getByText('Look for incoming data that matches the foos in the service'),
).toBeInTheDocument();
expect(getByText('Foos to Match On')).toBeInTheDocument();
expect(getByText('The foos that identify the row(s) to modify')).toBeInTheDocument();
expect(
getByText(
'The foos to use when matching rows in the service to the input items of this node. Usually an ID.',
),
).toBeInTheDocument();
});

it('should render correct fields based on saved schema', async () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/editor-ui/src/plugins/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1491,8 +1491,8 @@
"resourceMapper.fetchingFields.errorMessage": "Can't get {fieldWord}.",
"resourceMapper.fetchingFields.noFieldsFound": "No {fieldWord} found in {serviceName}.",
"resourceMapper.columnsToMatchOn.label": "{fieldWord} to Match On",
"resourceMapper.columnsToMatchOn.multi.description": "The {fieldWord} that identify the row(s) to modify",
"resourceMapper.columnsToMatchOn.single.description": "The {fieldWord} that identifies the row(s) to modify",
"resourceMapper.columnsToMatchOn.multi.description": "The {fieldWord} to use when matching rows in {nodeDisplayName} to the input items of this node. Usually an ID.",
"resourceMapper.columnsToMatchOn.single.description": "The {fieldWord} to use when matching rows in {nodeDisplayName} to the input items of this node. Usually an ID.",
"resourceMapper.columnsToMatchOn.tooltip": "The {fieldWord} to compare when finding the rows to update",
"resourceMapper.columnsToMatchOn.noFieldsFound": "No {fieldWord} that can be used for matching found in {serviceName}.",
"resourceMapper.valuesToSend.label": "Values to Send",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,18 @@ export async function execute(
} else {
const valueToMatchOn =
nodeVersion < 4
? (this.getNodeParameter('valueToMatchOn', i) as string)
: (this.getNodeParameter(`columns.value[${columnsToMatchOn[0]}]`, i) as string);
? (this.getNodeParameter('valueToMatchOn', i, '') as string)
: (this.getNodeParameter(`columns.value[${columnsToMatchOn[0]}]`, i, '') as string);

if (valueToMatchOn === '') {
throw new NodeOperationError(
this.getNode(),
"The 'Column to Match On' parameter is required",
{
itemIndex: i,
},
);
}

if (nodeVersion < 4) {
const valuesToSend = this.getNodeParameter('fieldsUi.values', i, []) as IDataObject[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,18 @@ export async function execute(
} else {
const valueToMatchOn =
nodeVersion < 4
? (this.getNodeParameter('valueToMatchOn', i) as string)
: (this.getNodeParameter(`columns.value[${columnsToMatchOn[0]}]`, i) as string);
? (this.getNodeParameter('valueToMatchOn', i, '') as string)
: (this.getNodeParameter(`columns.value[${columnsToMatchOn[0]}]`, i, '') as string);

if (valueToMatchOn === '') {
throw new NodeOperationError(
this.getNode(),
"The 'Column to Match On' parameter is required",
{
itemIndex: i,
},
);
}

if (nodeVersion < 4) {
const valuesToSend = this.getNodeParameter('fieldsUi.values', i, []) as IDataObject[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const properties: INodeProperties[] = [
loadOptionsDependsOn: ['schema.value', 'table.value'],
},
default: '',
hint: 'The column that identifies the row(s) to modify',
hint: 'The column to use when matching rows in Postgres to the input items of this node. Usually an ID.',
displayOptions: {
show: {
'@version': [2, 2.1],
Expand Down

0 comments on commit ce46bf5

Please sign in to comment.