node-mssql
node-mssql copied to clipboard
Using useColumnNames is triggering error "columns is not iterable"
Expected behaviour:
The use of useColumnNames should not thrown an error on query
Actual behaviour:
TypeError: columns is not iterable
at Request.<anonymous> (/home/user/dev/rece-tech-web-bo/node_modules/mssql/lib/tedious/request.js:600:29)
at Request.emit (node:events:527:28)
at Request.emit (/home/user/dev/rece-tech-web-bo/node_modules/tedious/lib/request.js:150:18)
at RequestTokenHandler.onRow (/home/user/dev/rece-tech-web-bo/node_modules/tedious/lib/token/handler.js:457:20)
at Readable.<anonymous> (/home/user/dev/rece-tech-web-bo/node_modules/tedious/lib/token/token-stream-parser.js:26:33)
at Readable.emit (node:events:527:28)
at addChunk (node:internal/streams/readable:315:12)
at readableAddChunk (node:internal/streams/readable:289:9)
at Readable.push (node:internal/streams/readable:228:10)
at next (node:internal/streams/from:98:31)
Emitted 'error' event on Readable instance at:
at emitErrorNT (node:internal/streams/destroy:157:8)
at emitErrorCloseNT (node:internal/streams/destroy:122:3)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
When useColumnNames is true, columns = {ID_Login: {…}, Testeur: {…}, Login: {…}, Mail: {…}, IsSupervisor: {…}}
When useColumnNames is false, columns = (5) [{…}, {…}, {…}, {…}, {…}]
I do not have this behavior using tedious as standalone.
Code:
const request = new sql.Request(this.sqlPool)
request.input("@param", TYPES.NVarChar, "test")
request.query(query)
const res: SQLResult[][] = []
request.on('row', (columns) => {
console.log("received row: " + JSON.stringify(columns))
})
Configuration:
{
"server": "",
"database": "",
"user": "",
"password": "",
"pool": {
"max": 10,
"min": 0,
"idleTimeoutMillis": 30000
},
"options": {
"trustServerCertificate": true,
"useColumnNames": true
}
}
Software versions
- NodeJS: V16.15.1
- node-mssql: 8.1.2
- SQL Server: 2012 Server
It looks like useColumnNames
is a config option for the tedious driver which is equivalent to arrayRowMode
in this library.
As we already duplicate this functionality I think it's better that we simply block this library from accepting that tedious config and instead force users to use the built-in config instead
this has been fixed in #1416 and released in v8.1.3 and v9.0.0
If this option is set to anything except true
, it causes an error to be thrown