feat(Merge Node): Better pairedItem mapping in combineBySql operation if SELECT query (#13849)

Co-authored-by: Shireen Missi <94372015+ShireenMissi@users.noreply.github.com>
This commit is contained in:
Michael Kret
2025-03-13 12:20:44 +02:00
committed by GitHub
parent d2e4706b97
commit 881d3f8771
6 changed files with 368 additions and 24 deletions

View File

@@ -259,6 +259,142 @@ describe('Test MergeV3, combineBySql operation', () => {
country: 'PL',
});
});
it('should collect pairedItems data, if version >= 3.1 and SELECT query', async () => {
const nodeParameters: IDataObject = {
operation: 'combineBySql',
query: 'SELECT name FROM input1 LEFT JOIN input2 ON input1.id = input2.id',
};
const inputs = [
[
{
json: {
id: 1,
data: 'a',
name: 'Sam',
},
pairedItem: {
item: 0,
input: undefined,
},
},
{
json: {
id: 2,
data: 'b',
name: 'Dan',
},
pairedItem: {
item: 1,
input: undefined,
},
},
{
json: {
id: 3,
data: 'c',
name: 'Jon',
},
pairedItem: {
item: 2,
input: undefined,
},
},
],
[
{
json: {
id: 1,
data: 'aa',
country: 'PL',
},
pairedItem: {
item: 0,
input: 1,
},
},
{
json: {
id: 2,
data: 'bb',
country: 'FR',
},
pairedItem: {
item: 1,
input: 1,
},
},
{
json: {
id: 3,
data: 'cc',
country: 'UA',
},
pairedItem: {
item: 2,
input: 1,
},
},
],
];
const returnData = await mode.combineBySql.execute.call(
createMockExecuteFunction(nodeParameters, { ...node, typeVersion: 3.1 }),
inputs,
);
expect(returnData.length).toEqual(1);
expect(returnData).toEqual([
[
{
json: {
name: 'Sam',
},
pairedItem: [
{
item: 0,
input: undefined,
},
{
item: 0,
input: 1,
},
],
},
{
json: {
name: 'Dan',
},
pairedItem: [
{
item: 1,
input: undefined,
},
{
item: 1,
input: 1,
},
],
},
{
json: {
name: 'Jon',
},
pairedItem: [
{
item: 2,
input: undefined,
},
{
item: 2,
input: 1,
},
],
},
],
]);
});
});
describe('Test MergeV3, append operation', () => {