node-mssql: TypeError => 'validate' of undefined (prototype leakage)
Hi all.
Here is a part of my code:
var importDb = function() {
sql.connect(connectionString).then(function() {
console.log('connected'); ///////////////////////////////////// UNTIL HERE IS OK
var query = 'SELECT TOP 10 * FROM ' + mRecord.view_path + ';'; // I'M SURE QUERY IS OK
console.log('starting, with query: ' + query);
var request = new sql.Request();
request.query(query).then(function(recordset) {
console.log('data successfully retrieved'); ///////////////// NEVER GETS EXECUTED
}).catch(function(err) {
console.log(err);
});
});
}
OK, to be honest, when I create a completely new project with this snippet, everything works perfectly but in my development project, the line where is .then(recordset) is throwing the error:
[TypeError: Cannot read property ‘validate’ of undefined]
Do you have a hint why? If you need more info, feel free to ask.
Node versions (nvm): 5.1.0 5.3.0 5.5.0
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 22
Applying the changes from #879 into my project worked for me
This answer was the issue in my case. My teammate was using
TYPES.NvarCharinstead ofTYPES.NVarCharBTW, the sample code link is no longer pointing to the right line of code.
I also can reproduce this error when including adding a function to Object.prototype. The cause is mssql’s tedious.js, which does not check “hasOwnProperty” when looping through the names in this.parameters. Because the Object.prototype.[function] exists on this, an invalid output parameter is added. See example of problem code below:
I’m not able to reproduce the issue. The error you get is because of invalid type of an input parameter. It’s happening on this line. But the request you’re creating in your sample has no parameters. Are you sure you’re getting this error with exactly this sample code?