mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-21 02:56:40 -08:00
feat(core): Autofix pairedItem information if inputItems(n) === outputItems(n)
This commit is contained in:
parent
7fc7b65c15
commit
68fb1c64dc
|
@ -945,21 +945,33 @@ export class WorkflowExecute {
|
||||||
if (outputData === null) {
|
if (outputData === null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (const item of outputData) {
|
for (const [index, item] of outputData.entries()) {
|
||||||
if (!item.pairedItem) {
|
if (!item.pairedItem) {
|
||||||
// The pairedItem is missing so check if it can get automatically fixed
|
// The pairedItem data is missing, so check if it can get automatically fixed
|
||||||
if (
|
if (
|
||||||
executionData.data.main.length !== 1 ||
|
executionData.data.main.length === 1 &&
|
||||||
executionData.data.main[0]?.length !== 1
|
executionData.data.main[0]?.length === 1
|
||||||
) {
|
) {
|
||||||
// Automatically fixing is only possible if there is only one
|
// The node has one input and one incoming item, so we know
|
||||||
// input and one input item
|
// that all items must originate from that single
|
||||||
|
item.pairedItem = {
|
||||||
|
item: 0,
|
||||||
|
};
|
||||||
|
} else if (
|
||||||
|
nodeSuccessData.length === 1 &&
|
||||||
|
executionData.data.main.length === 1 &&
|
||||||
|
executionData.data.main[0]?.length === nodeSuccessData[0].length
|
||||||
|
) {
|
||||||
|
// The node has one input and one output. The number of items on both is
|
||||||
|
// identical so we can make the resonable asumption that each of the input
|
||||||
|
// items is the origin of the corresponding output items
|
||||||
|
item.pairedItem = {
|
||||||
|
item: index,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
// In all other cases is autofixing not possible
|
||||||
break checkOutputData;
|
break checkOutputData;
|
||||||
}
|
}
|
||||||
|
|
||||||
item.pairedItem = {
|
|
||||||
item: 0,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue