question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When using sql.Int parameter type = parameter.type.validate is not a function

See original GitHub issue

I’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:closed
  • Created 8 years ago
  • Comments:8

github_iconTop GitHub Comments

9reactions
rdavidsocommented, Dec 15, 2017

I can also confirm with @CollinEstes that having two different imported versions of mssql results in this exact same issue.

2reactions
thiagotigazcommented, Feb 6, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found