mirror of
https://github.com/n8n-io/n8n.git
synced 2026-05-31 08:46:58 +02:00
fix(Google Sheets Node): Handle undefined lookup values in lookupValues (#31055)
This commit is contained in:
parent
35791f7b27
commit
7348f928c8
|
|
@ -239,6 +239,38 @@ describe('GoogleSheet', () => {
|
|||
expect(result).toEqual([{ name: 'John', age: '30', city: 'NY' }]);
|
||||
});
|
||||
|
||||
it('should ignore undefined lookup values without throwing (OR)', async () => {
|
||||
const lookupValues = [{ lookupColumn: 'age', lookupValue: undefined }];
|
||||
|
||||
const result = await googleSheet.lookupValues({
|
||||
inputData,
|
||||
keyRowIndex: 0,
|
||||
dataStartRowIndex: 1,
|
||||
lookupValues,
|
||||
returnAllMatches: true,
|
||||
combineFilters: 'OR',
|
||||
nodeVersion: 4.5,
|
||||
});
|
||||
|
||||
expect(result).toEqual([]);
|
||||
});
|
||||
|
||||
it('should ignore undefined lookup values without throwing (AND)', async () => {
|
||||
const lookupValues = [{ lookupColumn: 'age', lookupValue: undefined }];
|
||||
|
||||
const result = await googleSheet.lookupValues({
|
||||
inputData,
|
||||
keyRowIndex: 0,
|
||||
dataStartRowIndex: 1,
|
||||
lookupValues,
|
||||
returnAllMatches: true,
|
||||
combineFilters: 'AND',
|
||||
nodeVersion: 4.5,
|
||||
});
|
||||
|
||||
expect(result).toEqual([]);
|
||||
});
|
||||
|
||||
it('should throw error for invalid key row', async () => {
|
||||
const lookupValues = [{ lookupColumn: 'age', lookupValue: '30' }];
|
||||
|
||||
|
|
|
|||
|
|
@ -737,7 +737,7 @@ export class GoogleSheet {
|
|||
for (rowIndex = dataStartRowIndex; rowIndex < inputData.length; rowIndex++) {
|
||||
if (
|
||||
inputData[rowIndex][returnColumnIndex]?.toString() ===
|
||||
lookupValue.lookupValue.toString()
|
||||
lookupValue.lookupValue?.toString()
|
||||
) {
|
||||
if (addedRows.indexOf(rowIndex) === -1) {
|
||||
returnData.push(inputData[rowIndex]);
|
||||
|
|
@ -769,7 +769,7 @@ export class GoogleSheet {
|
|||
|
||||
if (
|
||||
inputData[rowIndex][returnColumnIndex]?.toString() !==
|
||||
lookupValue.lookupValue.toString()
|
||||
lookupValue.lookupValue?.toString()
|
||||
) {
|
||||
allMatch = false;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ export interface ISheetUpdateData {
|
|||
|
||||
export interface ILookupValues {
|
||||
lookupColumn: string;
|
||||
lookupValue: string;
|
||||
lookupValue: string | number | boolean | null | undefined;
|
||||
}
|
||||
|
||||
export interface IToDeleteRange {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user