fix(editor): fix mapping bug when val is null (#3942)

This commit is contained in:
Mutasem Aldmour 2022-08-25 12:54:46 +02:00 committed by GitHub
parent dc576939aa
commit a21dbdc45b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View file

@ -45,6 +45,10 @@ export default Vue.extend({
}, },
methods: { methods: {
isSimple(data: unkown): boolean { isSimple(data: unkown): boolean {
if (data === null || data === undefined) {
return true;
}
if (typeof data === 'object' && Object.keys(data).length === 0) { if (typeof data === 'object' && Object.keys(data).length === 0) {
return true; return true;
} }

View file

@ -173,7 +173,7 @@ export default mixins(externalHooks).extend({
type: Object as () => INodeUi, type: Object as () => INodeUi,
}, },
inputData: { inputData: {
type: Object as () => INodeExecutionData[], type: Array as () => INodeExecutionData[],
}, },
mappingEnabled: { mappingEnabled: {
type: Boolean, type: Boolean,
@ -399,7 +399,7 @@ export default mixins(externalHooks).extend({
// Go over all keys of entry // Go over all keys of entry
entryRows = []; entryRows = [];
leftEntryColumns = Object.keys(entry); leftEntryColumns = Object.keys(entry || {});
// Go over all the already existing column-keys // Go over all the already existing column-keys
tableColumns.forEach((key) => { tableColumns.forEach((key) => {
@ -409,7 +409,7 @@ export default mixins(externalHooks).extend({
// Remove key so that we know that it got added // Remove key so that we know that it got added
leftEntryColumns.splice(leftEntryColumns.indexOf(key), 1); leftEntryColumns.splice(leftEntryColumns.indexOf(key), 1);
hasJson[key] = typeof entry[key] === 'object' || hasJson[key] || false; hasJson[key] = hasJson[key] || (typeof entry[key] === 'object' && Object.keys(entry[key] || {}).length > 0) || false;
} else { } else {
// Entry does not have key so add null // Entry does not have key so add null
entryRows.push(null); entryRows.push(null);
@ -422,7 +422,7 @@ export default mixins(externalHooks).extend({
tableColumns.push(key); tableColumns.push(key);
// Add the value // Add the value
entryRows.push(entry[key]); entryRows.push(entry[key]);
hasJson[key] = hasJson[key] || (entry[key] === 'object' && Object.keys(entry[key] || {}).length > 0); hasJson[key] = hasJson[key] || (typeof entry[key] === 'object' && Object.keys(entry[key] || {}).length > 0) || false;
}); });
// Add the data of the entry // Add the data of the entry