mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-20 03:12:15 +00:00
fix(Google Sheets Node): Return single row in read operation if combine conditions is OR and 'Return only First Matching Row' (#15095)
This commit is contained in:
@@ -103,14 +103,14 @@ describe('GoogleSheet', () => {
|
||||
});
|
||||
|
||||
describe('lookupValues', () => {
|
||||
it('should find matching rows with OR combination', async () => {
|
||||
const inputData = [
|
||||
['name', 'age', 'city'],
|
||||
['John', '30', 'NY'],
|
||||
['Jane', '25', 'LA'],
|
||||
['Bob', '30', 'SF'],
|
||||
];
|
||||
const inputData = [
|
||||
['name', 'age', 'city'],
|
||||
['John', '30', 'NY'],
|
||||
['Jane', '25', 'LA'],
|
||||
['Bob', '30', 'SF'],
|
||||
];
|
||||
|
||||
it('should find matching rows with OR combination', async () => {
|
||||
const lookupValues = [{ lookupColumn: 'age', lookupValue: '30' }];
|
||||
|
||||
const result = await googleSheet.lookupValues({
|
||||
@@ -120,6 +120,7 @@ describe('GoogleSheet', () => {
|
||||
lookupValues,
|
||||
returnAllMatches: true,
|
||||
combineFilters: 'OR',
|
||||
nodeVersion: 4.5,
|
||||
});
|
||||
|
||||
expect(result).toEqual([
|
||||
@@ -128,14 +129,46 @@ describe('GoogleSheet', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it('should find matching rows with AND combination', async () => {
|
||||
const inputData = [
|
||||
['name', 'age', 'city'],
|
||||
['John', '30', 'NY'],
|
||||
['Jane', '25', 'LA'],
|
||||
['Bob', '30', 'SF'],
|
||||
it('should find matching rows with OR combination and returnAllMatches is falsy at version 4.5', async () => {
|
||||
const lookupValues = [
|
||||
{ lookupColumn: 'age', lookupValue: '30' },
|
||||
{ lookupColumn: 'name', lookupValue: 'Jane' },
|
||||
];
|
||||
|
||||
const result = await googleSheet.lookupValues({
|
||||
inputData,
|
||||
keyRowIndex: 0,
|
||||
dataStartRowIndex: 1,
|
||||
lookupValues,
|
||||
combineFilters: 'OR',
|
||||
nodeVersion: 4.5,
|
||||
});
|
||||
|
||||
expect(result).toEqual([
|
||||
{ name: 'John', age: '30', city: 'NY' },
|
||||
{ name: 'Jane', age: '25', city: 'LA' },
|
||||
]);
|
||||
});
|
||||
|
||||
it('should find matching rows with OR combination and returnAllMatches is falsy at version 4.6', async () => {
|
||||
const lookupValues = [
|
||||
{ lookupColumn: 'age', lookupValue: '30' },
|
||||
{ lookupColumn: 'name', lookupValue: 'Jane' },
|
||||
];
|
||||
|
||||
const result = await googleSheet.lookupValues({
|
||||
inputData,
|
||||
keyRowIndex: 0,
|
||||
dataStartRowIndex: 1,
|
||||
lookupValues,
|
||||
combineFilters: 'OR',
|
||||
nodeVersion: 4.6,
|
||||
});
|
||||
|
||||
expect(result).toEqual([{ name: 'John', age: '30', city: 'NY' }]);
|
||||
});
|
||||
|
||||
it('should find matching rows with AND combination', async () => {
|
||||
const lookupValues = [
|
||||
{ lookupColumn: 'age', lookupValue: '30' },
|
||||
{ lookupColumn: 'city', lookupValue: 'NY' },
|
||||
@@ -148,21 +181,22 @@ describe('GoogleSheet', () => {
|
||||
lookupValues,
|
||||
returnAllMatches: true,
|
||||
combineFilters: 'AND',
|
||||
nodeVersion: 4.5,
|
||||
});
|
||||
|
||||
expect(result).toEqual([{ name: 'John', age: '30', city: 'NY' }]);
|
||||
});
|
||||
|
||||
it('should throw error for invalid key row', async () => {
|
||||
const inputData = [['name', 'age']];
|
||||
const lookupValues = [{ lookupColumn: 'age', lookupValue: '30' }];
|
||||
|
||||
await expect(
|
||||
googleSheet.lookupValues({
|
||||
inputData,
|
||||
inputData: [['name', 'age']],
|
||||
keyRowIndex: -1,
|
||||
dataStartRowIndex: 1,
|
||||
lookupValues,
|
||||
nodeVersion: 4.5,
|
||||
}),
|
||||
).rejects.toThrow('The key row does not exist');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user