jung-thomas / sap-hdbext-promisfied

Moved to https://github.com/SAP-samples/hana-hdbext-promisfied-example
https://github.com/SAP-samples/hana-hdbext-promisfied-example
Apache License 2.0
2 stars 1 forks source link

callProcedurePromisified does not return all output variables #1

Closed Arthesian closed 4 years ago

Arthesian commented 4 years ago

Hi,

I'm using your package for a NodeJS API connecting to a HANA DB.

The only issue i'm experiencing so far is that when a Procedure returns mutliple output variables, only the first one is returned.

The issue lies with the callback method here: https://github.com/jungsap/sap-hdbext-promisfied/blob/master/index.js#L29

It probably should be something like:

storedProc(inputParams, (error, outputScalar, ...results) => {
    if (error) {
        reject(error);
    } else {
        resolve({
            outputScalar: outputScalar,
            results: results
        });
    }
});

This way multiple output variables can be captured in an array - and everything is returned properly.

Thanks

Arthesian commented 4 years ago

Or, to prevent a breaking change you could do something like this:

storedProc(inputParams, (error, outputScalar, results, ...other) => {
    if (error) {
        reject(error);
    } else {
        resolve({
            outputScalar: outputScalar,
            results: results,
            other: other
        });
    }
});
jung-thomas commented 4 years ago

Actually I already have a little better version of this module used in other projects directly where I use the ...results approach. This weekend I'll sync the newer version into this standalone module. You see this newer version as part of the openSAP course materials here: https://github.com/SAP/hana-xsa-opensap-hana7/blob/hana2_sps04_scp/srv/utils/dbPromises.js#L47

Arthesian commented 4 years ago

Ah okay. Cool. Thanks for the update!