fix(Google Sheets Node): Update to returnAllMatches option (#10440)

Co-authored-by: Shireen Missi <shireen@n8n.io>
This commit is contained in:
Michael Kret 2024-08-16 18:35:22 +03:00 committed by GitHub
parent ce46bf516a
commit f7fb02e92a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 27 additions and 3 deletions

View file

@ -11,7 +11,7 @@ export class GoogleSheets extends VersionedNodeType {
name: 'googleSheets',
icon: 'file:googleSheets.svg',
group: ['input', 'output'],
defaultVersion: 4.4,
defaultVersion: 4.5,
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
description: 'Read, update and write data to Google Sheets',
};
@ -25,6 +25,7 @@ export class GoogleSheets extends VersionedNodeType {
4.2: new GoogleSheetsV2(baseDescription),
4.3: new GoogleSheetsV2(baseDescription),
4.4: new GoogleSheetsV2(baseDescription),
4.5: new GoogleSheetsV2(baseDescription),
};
super(nodeVersions, baseDescription);

View file

@ -135,6 +135,19 @@ export const description: SheetProperties = [
options: [
dataLocationOnSheet,
outputFormatting,
{
displayName: 'Return only First Matching Row',
name: 'returnFirstMatch',
type: 'boolean',
default: false,
description:
'Whether to select the first row of the sheet or the first matching row (if filters are set)',
displayOptions: {
show: {
'@version': [{ _cnd: { gte: 4.5 } }],
},
},
},
{
displayName: 'When Filter Has Multiple Matches',
name: 'returnAllMatches',
@ -154,6 +167,11 @@ export const description: SheetProperties = [
],
description:
'By default only the first result gets returned, Set to "Return All Matches" to get multiple matches',
displayOptions: {
show: {
'@version': [{ _cnd: { lt: 4.5 } }],
},
},
},
],
},
@ -219,7 +237,12 @@ export async function execute(
const inputData = data as string[][];
if (lookupValues.length) {
const returnAllMatches = options.returnAllMatches === 'returnAllMatches' ? true : false;
let returnAllMatches;
if (nodeVersion < 4.5) {
returnAllMatches = options.returnAllMatches === 'returnAllMatches' ? true : false;
} else {
returnAllMatches = options.returnFirstMatch ? false : true;
}
if (nodeVersion <= 4.1) {
for (let i = 1; i < items.length; i++) {

View file

@ -9,7 +9,7 @@ export const versionDescription: INodeTypeDescription = {
name: 'googleSheets',
icon: 'file:googleSheets.svg',
group: ['input', 'output'],
version: [3, 4, 4.1, 4.2, 4.3, 4.4],
version: [3, 4, 4.1, 4.2, 4.3, 4.4, 4.5],
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
description: 'Read, update and write data to Google Sheets',
defaults: {