mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-20 03:12:15 +00:00
feat(Google Sheets Node): Option how to combine filters when reading rows (#8652)
This commit is contained in:
@@ -282,3 +282,121 @@ describe('Test Google Sheets, autoMapInputData', () => {
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Test Google Sheets, lookupValues', () => {
|
||||
const inputData = [
|
||||
['row_number', 'id', 'num', 'text'],
|
||||
[2, 1, '111', 'bar'],
|
||||
[3, 3, 1, 'bar'],
|
||||
[4, 4, 1, 'baz'],
|
||||
[5, 5, 1, 'baz'],
|
||||
[6, 6, 66, 'foo'],
|
||||
[7, 7, 77, 'foo'],
|
||||
] as string[][];
|
||||
|
||||
it('should return rows by combining filters by OR', async () => {
|
||||
const fakeExecuteFunction = {
|
||||
getNode() {
|
||||
return {};
|
||||
},
|
||||
} as unknown as IExecuteFunctions;
|
||||
|
||||
const googleSheet = new GoogleSheet('spreadsheetId', fakeExecuteFunction);
|
||||
|
||||
const result = await googleSheet.lookupValues(
|
||||
inputData,
|
||||
0,
|
||||
1,
|
||||
[
|
||||
{
|
||||
lookupColumn: 'num',
|
||||
lookupValue: '1',
|
||||
},
|
||||
{
|
||||
lookupColumn: 'text',
|
||||
lookupValue: 'foo',
|
||||
},
|
||||
],
|
||||
true,
|
||||
'OR',
|
||||
);
|
||||
|
||||
expect(result).toBeDefined();
|
||||
expect(result).toEqual([
|
||||
{
|
||||
row_number: 3,
|
||||
id: 3,
|
||||
num: 1,
|
||||
text: 'bar',
|
||||
},
|
||||
{
|
||||
row_number: 4,
|
||||
id: 4,
|
||||
num: 1,
|
||||
text: 'baz',
|
||||
},
|
||||
{
|
||||
row_number: 5,
|
||||
id: 5,
|
||||
num: 1,
|
||||
text: 'baz',
|
||||
},
|
||||
{
|
||||
row_number: 6,
|
||||
id: 6,
|
||||
num: 66,
|
||||
text: 'foo',
|
||||
},
|
||||
{
|
||||
row_number: 7,
|
||||
id: 7,
|
||||
num: 77,
|
||||
text: 'foo',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('should return rows by combining filters by AND', async () => {
|
||||
const fakeExecuteFunction = {
|
||||
getNode() {
|
||||
return {};
|
||||
},
|
||||
} as unknown as IExecuteFunctions;
|
||||
|
||||
const googleSheet = new GoogleSheet('spreadsheetId', fakeExecuteFunction);
|
||||
|
||||
const result = await googleSheet.lookupValues(
|
||||
inputData,
|
||||
0,
|
||||
1,
|
||||
[
|
||||
{
|
||||
lookupColumn: 'num',
|
||||
lookupValue: '1',
|
||||
},
|
||||
{
|
||||
lookupColumn: 'text',
|
||||
lookupValue: 'baz',
|
||||
},
|
||||
],
|
||||
true,
|
||||
'AND',
|
||||
);
|
||||
|
||||
expect(result).toBeDefined();
|
||||
expect(result).toEqual([
|
||||
{
|
||||
row_number: 4,
|
||||
id: 4,
|
||||
num: 1,
|
||||
text: 'baz',
|
||||
},
|
||||
{
|
||||
row_number: 5,
|
||||
id: 5,
|
||||
num: 1,
|
||||
text: 'baz',
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user