String length from 2001 to 4000 bytes throws error on msnodesqlv8
This example throws error. In direct using msnodesqlv8 it`s OK. (https://github.com/TimelordUK/node-sqlserver-v8/wiki#strings)
'use strict'
const mssql = require('mssql')
const STR_LEN = 2001
const str = '1'.repeat(STR_LEN)
const sqlConfig = {
driver: 'msnodesqlv8',
server: 'SYPSQL',
options: {
trustedConnection: true,
useUTC: true
}
}
mssql.connect(sqlConfig)
.then(() => {
return new mssql.Request()
.input('str', mssql.NVarChar(mssql.MAX), str)
.query('DECLARE @s NVARCHAR(MAX) = @str; SELECT @s AS s')
.then((req) => {
console.log(req)
})
.catch((err) => {
console.error(err)
})
})
+1
I'm always getting the error: "Invalid precision value".
I'm thinking about contributing and fixing this bug, but what do you think @patriksimek would be the best? Concerning this issue TimelordUK/node-sqlserver-v8#24 i'm not shure if the owner of this repository really has an intention to fix this because you could use the sql.WLongVarChar-Type.
So, should we just add a little hotfix to take sql.WLongVarChar on calling the node-sqlserver-v8 driver if the NVarchar's length is greater than 2000 our would you prefer to getting this fixed on the driver-repo?
I don't think that providing the sql.WLongVarChar-type on your lib is an option for you because it doesn't exist on the tds, right?
I have set up a branch for this - https://github.com/patriksimek/node-mssql/compare/issue-438
We can't use WLongVarChar directly in mssql because it is ODBC type. Right now I'm checking for MAX length on type definition but it would be propably better to check for actual string length. Problem is, what is going to happen when someone sends a non-string variable to this parameter? And what about other types like VarChar, Text, NText, Char, NChar, XML? This needs some more testing, but I don't have a free time for this atm. Feel free to contribute.
this has been fixed finally in 0.6.3,
thanks for the patience
https://github.com/TimelordUK/node-sqlserver-v8/releases/tag/0.6.3
OK - so it appears this was fixed in the upstream lib so we can close...