Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 31 14:34
    willmorgan commented on 889cbf1
  • Jan 31 13:15
    gsamal commented on 889cbf1
  • Jan 31 13:10
    dhensby closed #797
  • Jan 31 13:10
    dhensby commented #797
  • Jan 31 13:07
    dhensby closed #795
  • Jan 31 13:07
    dhensby commented #795
  • Jan 31 12:58
    gsamal commented #789
  • Jan 31 11:50
    cesco69 opened #797
  • Jan 31 10:22

    dhensby on master

    Update changelog for v5 Merge pull request #796 from dh… (compare)

  • Jan 31 10:22
    dhensby closed #796
  • Jan 31 09:53
    dhensby commented #789
  • Jan 31 09:52
    dhensby commented #778
  • Jan 31 09:51
    dhensby review_requested #796
  • Jan 31 09:51
    dhensby opened #796
  • Jan 31 06:45
    suckerp commented #795
  • Jan 31 02:58
    liumorgan starred tediousjs/node-mssql
  • Jan 31 02:15
    zhoukk starred tediousjs/node-mssql
  • Jan 30 22:22
    vjpr edited #795
  • Jan 30 22:22
    vjpr edited #795
  • Jan 30 22:22
    vjpr opened #795
andrew bernard
@drexler
thanks a lot. i'll dig in more.
Ali Peyman
@alipeyman1997_gitlab
Hi, I`m using SQL server for my node project, what is the best module for preventing SQL injection?
and Which modules do you use for your security?
David Gasperoni
@mcdado
Hmm, I thought if you pass values to input parameters you can’t get SQL Injections
Igor Savin
@kibertoad
There is currently an ongoing discussion in the repo regarding dropping Node 4 support; is anyone in the channel still running Node 4 on a server?
Mikhail Maslyuk
@Mikhail-MM
What exactly is the difference between using the mssql vs the tedious package from npm? At a glance the code for both seems fairly similar?
andrew bernard
@drexler
@Mikhail-MM mssql is a higher-level abstraction which uses tedious as its driver.
Alex Tunick
@AlexanderTunick
Hi! Guys, can't succeed in querying for only one out of all my tests where get
RequestError: Conversion failed when converting the varchar value '1.93' to data type int.
Though this query successfully passes in Data Grip, don't you know why does tedious complain?
RequestError: Conversion failed when converting the varchar value '1.93' to data type int.
    at handleError (node_modules/mssql/lib/tedious.js:519:15)
    at Parser.<anonymous> (node_modules/tedious/lib/connection.js:618:16)
    at Parser.<anonymous> (node_modules/tedious/lib/token/token-stream-parser.js:54:15)
    at addChunk (node_modules/readable-stream/lib/_stream_readable.js:291:12)
    at readableAddChunk (node_modules/readable-stream/lib/_stream_readable.js:278:11)
    at Parser.Readable.push (node_modules/readable-stream/lib/_stream_readable.js:245:10)
P.S a workable query is written out from Knex plan that uses mssql as client, so the query is correct and is being successfully run in Data Grip
Jason Luboff
@JLuboff
@Alextunchii It's failing due to 1.93 not being a valid int value. An integer is a whole number. You would need to convert to decimal or numeric
Alex Tunick
@AlexanderTunick
@JLuboff but, once again, I successfully querying this in Data Grip IDE but with help of mssql client I see this, why is it not proceeded?
Jason Luboff
@JLuboff
I'm not familar with Data Grip, so I can't answer that. Its possible that the IDE is transforming the data in some way.
Alex Tunick
@AlexanderTunick

Hi guys! Could you please explain to me is it ok to have connection status "sleeping" on SQL server after querying DB with node-mssql
I have this simple method:

async queryDatabase(queryOption) {
        try {
            // const pool = new sql.ConnectionPool(this.getConfigCsdb());
            let connection = await pool.connect(this.getConfigCsdb());
            let result = await connection.request().query(queryOption);
            result = result['recordset'][0][''];
            return result;
        } catch (e) {
            throw e;
        } finally {
            await connection.close();
        }
    }

Which works perfectly but want to confirm that it closes a connection.
After querying Database, using EXEC sp_who2; I see the connection bridge visible in the list of processes:

sleeping    Alexanders-MacBook-Pro-3.local    node-mssql

when I running query I'm observing status to be changed to "RUNNABLE" and after finishing it becomes "sleeping".

Should it be like that or it should vanish at all from the list of connection shown in EXEC sp_who2;?

Daniel Hensby
@dhensby
What version of the mssql lib is it? What do the docs say about sleeping connections?
Alex Tunick
@AlexanderTunick
"mysql": "^2.16.0",
I haven't found any mention about sleeping in the docs of node-mssql
it just says that close()
Close all active connections in the pool.
And I would be grateful to know in which status it leaves connection ultimately
Daniel Hensby
@dhensby
Mysql? V2? That's not this lib, then
I think it's an operating system level issue and not to do with the lib.
It's nothing to worry about unless you start seeing hundreds of connections
Alex Tunick
@AlexanderTunick
miscopied "mssql": "4.1.0",
Daniel Hensby
@dhensby
You'll want to upgrade. That's very old and there have been lots of improvements around pooling. But I also suspect this is just an internal quirk of SQL Server
Alex Tunick
@AlexanderTunick
Yeah, I also suspect it. About upgrade I would, but I use knex query builder that doesn't work with the last version, though some time has flown, need to recheck the last co-workable version
Daniel Hensby
@dhensby
It does now, I've worked extensively on improving that.
Alex Tunick
@AlexanderTunick
@dhensby wow, good news, thank you very much for informing me!
Daniel Hensby
@dhensby
👍
mn567
@mn567
The connect example here is wrong: https://www.npmjs.com/package/mssql#connection-pools
const pool2 = new sql.ConnectionPool(config, err => {
// ... error checks
}).connect();
I get an error saying already connecting
also connect() returns promise which gives error on the next line
pool2.on('error', err => {
// ... error handler
})
David Gasperoni
@mcdado
If you put a callback it will already start connecting
Either omit the callback and use the promise, or embrace callback hell
Daniel Hensby
@dhensby
@mn567 yes, they are wrong - issue #844 , fix #846 - fixed in v6 docs
dhaneshhs
@dhaneshhs
is there any sql query generator which works well with mssql which support easy way of generating INSERT query as i have more than 30 columns to be inserted to the table
Daniel Hensby
@dhensby
dhaneshhs
@dhaneshhs
Thanks @dhensby
TK
@tonnykayage
Mssql inducing memory leaks when i run a benchmark at 10k concurrency, Memory increases overtime until i'm out of memory.
_g[conn].request().query(preparedQuery, function (err, records) {
_g[conn].on('error', errdb => {
reject(_t.i(1005, configurations.errors, errdb));
Logger.log("error", "tmsmssql", "SYS", _t.i(1005, configurations.errors, errdb));
return;
});
if (err) {
reject(_t.i(1003, configurations.errors, JSON.stringify(err)));
} else {
if (records.rowsAffected[0] > 0) {
if (op === 'INSERT' || op === 'UPDATE' || op === 'DELETE') {
resolve(_t.i(200, null, records));
} else {
resolve(_t.i(200, null, records.recordset));
}
} else {
reject(_t.i(1004, configurations.errors));
}
}
});
Igor Savin
@kibertoad
Which mmsql version are you running?
TK
@tonnykayage
Mssql 5.1.0 @kibertoad
Taldrit
@Taldrit
I have a problem with the tutorial. I tried the ConnectionPool and always got the message that .on() is not a function and then I commented that out and tried it without, but now I get the error Already connecting to database. What did I do wrong?
const mssql = require('mssql');
let config = {...}; // that one is correct, I tested it with a pure simple query
const sqlPool = new mssql.ConnectionPool(config, err => {
console.log(err);
}).connect();
sqlPool.on('error', err => {
log(err);
});
const sqlQuery = queryString => {
return sqlPool.then(pool => {
pool.request().query(queryString)
}).then(result => {
console.dir(result);
})
};
sqlQuery("SELECT * FROM users");
David Gasperoni
@mcdado
If you pass a callback to ConnectionPool, it will not return a promise

Instead of this

mssql.ConnectionPool(config, err => { console.log(err);

Try like this:

mssql.ConnectionPool(config) .then((result) => {}) .catch((reason) => {});

Error handling is in the catch
.catch((reason) => {
    console.error(reason);
});
Taldrit
@Taldrit
grrrr... no I get the error: TypeError: (intermediate value).then is not a function
maybe I need a complete functioning module to adjust to my needs instead of small code samples. Do you have an example that I could use? I search for one that uses one connection for a long time (there maybe many calls to the same database from the same server without any other connections. So 1 connection that stays open for a longer time should be fine). The samples I found and that work all use a single call on a connection inside the connection call. But that way the connection would have to be closed and reopened on every query.
David Gasperoni
@mcdado
I think I know what you mean, personally I created a class that is technically a singleton for each database. Basically the connectionPool is module variable that calling modules access to. Then anytime I want to run requests I listen to the (already happened) on(“connect”) event
John McCallister
@mccallister_ftw_twitter
Hello