mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
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:
@@ -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', () => {
|
||||
|
||||
Reference in New Issue
Block a user