When using sql.Int parameter type = parameter.type.validate is not a function
See original GitHub issueI’m attempting to execute a query with a number(.Int) parameter type.
My parameter/query looks like this:
var arg = { name: 'id', type: sql.Int, value: 1 };
req.input(arg.name, arg.type, arg.value);
req.query(myQuery, cb);
When it tries to execute that query I get an error in tedious:
.../node_modules/mssql/node_modules/tedious/lib/request.js:144
value = parameter.type.validate(parameter.value);
^
TypeError: parameter.type.validate is not a function
When I omit the type from the “req.input” it runs fine, it also runs find if I use NVarChar as the type. The SQL column I’m using that parameter to check against in a WHERE clause is a Int, identity column so I feel like sql.Int is the right type for me.
Can anyone explain why I’m getting this error?
Issue Analytics
- State:
- Created 8 years ago
- Comments:8
Top Results From Across the Web
Validation failed for parameter 'request_UserID'. Cannot read ...
The solution was to change TYPES.VARCHAR to TYPES.VarChar. Thanks @AlwaysLearning.
Read more >When using sql.Int parameter type = parameter.type.validate is ...
I'm attempting to execute a query with a number(.Int) parameter type. My parameter/query looks like this: var arg = { name: 'id', type:...
Read more >VALIDATE Function SQL Compilation error
It gives me "SQL compilation error: invalid value [☺☺☺☺☺☺☺☺☺☺☺] for parameter 'TYPE'". Here are the commands which i executed. COPY INTO TBL_TEST ( ......
Read more >SqlParameter Class (System.Data.SqlClient) - Microsoft Learn
Command objects use parameters to pass values to SQL statements or stored procedures, providing type checking and validation in ADO.NET. SqlCommand.
Read more >Db2 11 - Db2 SQL - CREATE FUNCTION (sourced) - IBM
The USAGE privilege on each distinct type that the function references. ... The name is an SQL identifier, and each name in the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I can also confirm with @CollinEstes that having two different imported versions of mssql results in this exact same issue.
I found out this happens when using knex and mssql and having two different modules using mssql. Even though it’s the same version it fails, I’m having to require mssql in the same module that starts the knex connection and then inject it in the other module. If I do require mssql in the other module that doesn’t start knex it fails. This is crazy and took me a lot of time to figure out. My suspicion is that might modify the mssql dependency.