'Did node-mssql change its response shape between 6.3.0 and 6.4.0?
I am trying to update my node package from 5.1.0 to newest and on the first change to 6.4.1 its breaking immediately and I can't figure out what I need to do to fix it.
Its like the shape of the response obj is changed.
const fetchQueuedReport = async () => {
try {
const request = new sql.Request();
const response = await request.query(SELECT_QUEUED);
console.dir(response, { depth: null, colors: true });
const [report] = response.recordset;
return report;
} catch (error) {
console.error(error);
throw error;
}
};
In 5.1.0 the response I get as I am expecting is.
{ recordsets: [ [] ], recordset: [], output: {}, rowsAffected: [ 0 ] }
In 6.4.1 the response I am getting is
Mon, 09 May 2022 19:55:27 GMT tedious deprecated The default value for `config.options.enableArithAbort` will change from `false` to `true` in the next major version of `tedious`. Set the value to `true` or `false` explicitly to silence this message. at node_modules\mssql\lib\tedious\connection-pool.js:61:23
{ recordsets: null, recordset: null, output: {}, rowsAffected: [ 0 ] }
Notice recordsets and recordset are null now and no longer giving me the arrays I am expecting.
I can't find any documentation on what is wrong here or how to fix it so I get the results back that I am expecting from the DB.
Walking up the version tree it seems that it works until 6.3.2 and then at 6.4.0 it breaks on me.
Even 7.2.1 works for me and it was released before 6.4.0 release branch, but 7.3.0 released at the same time as 6.4.0 breaks for me the same way.
{ recordsets: null, recordset: null, output: {}, rowsAffected: [ 0 ] }
Solution 1:[1]
On GitHub, you can take a look at the changes between 2 versions like this. As you can see, very little was modified in the package itself between 6.3.2 and 6.4.0. Most of the changes listed come from updates of dependencies in the package-lock.json.
However, there is a change lib/base/request.js in the way arrayRowMode is set. My guess is that your problem comes from that since this configuration specifies the type of the returned sets: object or array. An empty set returned as an object must be null, while an empty set returned as an array must be an empty array.
To confirm my hypothesis, you should try to set arrayRowMode to true in your config file.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ben |
