Proposed solution: Data transformations return { } instead of null

*I’m still using Wappler v 3.9.6
**I know that altering core files is not a good practice, but I intend to share this as a possible fix for official implementation.

When using server-side Data transformation modules (ej: Join) if a value (as in key - value) is == null it is converted to the string: ’ { } '.

To solve this, ‘function clone’ in /lib/core/util.js could be adjusted as follows:

function clone(o) {
    if (Array.isArray(o)) {
        return o.map(clone);
    }

    +   if (o == null) {      
    +        return o;
    +    }  

    if (typeof o == 'object') {
        let oo = {};
        for (let key in o) {
            oo[key] = clone(o[key]);
        }
        return oo;
    }

    return o;
}

Maybe it is not perfect, but it’s working for my use case.

Regards.

Community Page
Last updated: