mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-21 02:56:40 -08:00
⚡ Add support for dot-notation in mode "mergeByKey" for Merge-Node
This commit is contained in:
parent
b7eab083e8
commit
3c8946ba7d
|
@ -1,3 +1,5 @@
|
||||||
|
import { get } from 'lodash';
|
||||||
|
|
||||||
import { IExecuteFunctions } from 'n8n-core';
|
import { IExecuteFunctions } from 'n8n-core';
|
||||||
import {
|
import {
|
||||||
GenericValue,
|
GenericValue,
|
||||||
|
@ -148,8 +150,6 @@ export class Merge implements INodeType {
|
||||||
|
|
||||||
|
|
||||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||||
// const itemsInput2 = this.getInputData(1);
|
|
||||||
|
|
||||||
const returnData: INodeExecutionData[] = [];
|
const returnData: INodeExecutionData[] = [];
|
||||||
|
|
||||||
const mode = this.getNodeParameter('mode', 0) as string;
|
const mode = this.getNodeParameter('mode', 0) as string;
|
||||||
|
@ -264,25 +264,26 @@ export class Merge implements INodeType {
|
||||||
} = {};
|
} = {};
|
||||||
let entry: INodeExecutionData;
|
let entry: INodeExecutionData;
|
||||||
for (entry of dataInput2) {
|
for (entry of dataInput2) {
|
||||||
if (!entry.json || !entry.json.hasOwnProperty(propertyName2)) {
|
const key = get(entry.json, propertyName2);
|
||||||
|
if (!entry.json || !key) {
|
||||||
// Entry does not have the property so skip it
|
// Entry does not have the property so skip it
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
copyData[entry.json[propertyName2] as string] = entry;
|
copyData[key as string] = entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy data on entries
|
// Copy data on entries
|
||||||
let referenceValue: GenericValue;
|
let referenceValue: GenericValue;
|
||||||
let key: string;
|
let key: string;
|
||||||
for (entry of dataInput1) {
|
for (entry of dataInput1) {
|
||||||
|
referenceValue = get(entry.json, propertyName1);
|
||||||
|
|
||||||
if (!entry.json || !entry.json.hasOwnProperty(propertyName1)) {
|
if (!referenceValue) {
|
||||||
// Entry does not have the property so skip it
|
// Entry does not have the property so skip it
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
referenceValue = entry.json[propertyName1];
|
|
||||||
|
|
||||||
if (!['string', 'number'].includes(typeof referenceValue)) {
|
if (!['string', 'number'].includes(typeof referenceValue)) {
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in a new issue