Releases: TimelordUK/node-sqlserver-v8
cancel query
https://github.com/TimelordUK/node-sqlserver-v8/wiki#cancel
this is a fairly major rework of the code to support query cancel and all users are advised to test carefully before upgrading production environments.
The driver will work exactly as previous versions but for queries submitted in polling mode, cancel is now enabled.
test('cancel single query from notifier using tmp connection - expect Operation canceled', function (test_done) {
var q = sql.query(conn_str, sql.PollingQuery("waitfor delay \'00:00:59\';"), function (err) {
assert(err);
assert(err.message.indexOf('Operation canceled') > 0);
test_done();
});
q.on('submitted', function () {
q.cancelQuery(function (err) {
assert(!err);
});
});
});
test('cancel single waitfor - expect Operation canceled', function (test_done) {
var q = theConnection.query(sql.PollingQuery("waitfor delay \'00:00:20\';"), function (err) {
assert(err);
assert(err.message.indexOf('Operation canceled') > 0);
test_done();
});
theConnection.cancelQuery(q, function (err) {
assert(!err);
});
});
- new event q.on('submitted', function () { } can be used to detect when a query is actually submitted to the driver. This can help in diagnostics and is necessary for cancels submitted on ad hoc queries such as above.
node v8 compatibility / multiple error via raiserror() support
- binaries included for new Node V8 version.
- chains of RAISEERROR will now be captured and returned allowing multiple errors to be managed.
$ node test\edge-case.js -t errors
[1] more = true err Error: [Microsoft][SQL Server Native Client 11.0][SQL Server][1]: Error Number 1 results null
[1] more = true err Error: [Microsoft][SQL Server Native Client 11.0][SQL Server][1]: Error Number 2 results null
[1] more = true err Error: [Microsoft][SQL Server Native Client 11.0][SQL Server][1]: Error Number 3 results null
[1] more = false err null results []
[1] completes more = false
setInterval( () => {
let qs = '';
let repeats = 3;
for (let i = 0; i < repeats; ++i) {
qs += `RAISERROR('[${x}]: Error Number ${i + 1}', 1, 1);`;
}
let q = conn.query(qs,
(err, results, more) => {
if (more && !err && results && results.length === 0) {
return;
}
console.log(`[${x}] more = ${more} err ${err} results ${JSON.stringify(results)}`);
if (more) return;
console.log(`[${x}] completes more = ${more}`);
++x;
});
q.on('msg', (err: v8Error) => {
//console.log(`[${x}]: q.msg = ${err.message}`);
});
}, delay);
connections stuck in busy state regarding error management.
final candidate release for error management improvements relating to RAISERROR ; select .... which now providing severity is < 14 will proceed to the following select having raised the error. In this case the more flag will be set true on the error raising event indicating more data will follow. If severity >= 14 then the statement is terminated and select will not be executed.
prior to this release it would be possible to get the connection in a permanent "busy" state where it can then not service further queries.
node test\edge-case.js -t busy --delay=5000 --severity=14
>> queryRaw
{ Error: [Microsoft][SQL Server Native Client 11.0][SQL Server]User JS Error sqlstate: '42000', code: 50000 }
null
<< queryRaw
>> queryRaw2
{ Error: [Microsoft][SQL Server Native Client 11.0][SQL Server]User JS Error sqlstate: '42000', code: 50000 }
null
<< queryRaw2
$ node test\edge-case.js -t busy --delay=5000 --severity=9
>> queryRaw
{ Error: [Microsoft][SQL Server Native Client 11.0][SQL Server]User JS Error sqlstate: '01000', code: 50000 }
null
>> queryRaw
null
{
"meta": null,
"rowcount": -1
}
>> queryRaw
null
{
"meta": [
{
"size": 10,
"name": "",
"nullable": true,
"type": "number",
"sqlType": "int"
}
],
"rows": [
[
2
]
bigint output parameters and re-patch folder baseline loader
broken Node v7
apologies, V7 was also not working and hence has been corrected.
add back node 4 binaries!
- small patch release to add back node 4 support, release on latest binaries across all node.
- small additions to the typescript module API
- additional test for module using prepared statements and refactor a little using the ASQ asyncquence.
pull request merge / typescript wrapper first draft
import {MsNodeSqlDriverApiModule as v8} from './lib/MsNodeSqlDriverApiModule'
export const sql: v8.v8driver = require('msnodesqlv8');
gain typing information by using the driver api mnodule. This is shown in use with the typescript mssql-demo.ts.
or use the promise based wrapper
import v8Meta = MsNodeSqlDriverApiModule.v8Meta;
import v8RawData = MsNodeSqlDriverApiModule.v8RawData;
import CommandResponse = MsNodeSqlWrapperModule.SqlCommandResponse;
import v8driver = MsNodeSqlDriverApiModule.v8driver;
import Connection = MsNodeSqlWrapperModule.Connection;
let sqlWrapper = new MsNodeSqlWrapperModule.Sql('use connection string');
// open connection, run query and close via a promise .....
sqlWrapper.execute(this.testSelect).then(res => {
assert.deepEqual(res.asObjects, this.expectedRows, "results didn't match");
resolve();
}).catch(e => reject(e));
look at DriverModuleTest.ts for other use cases such as event subscription or running a stored proc - return raw or object based results.
sqlWrapper.open().then(c=> {
let command = c.getCommand().sql(`select 1+1 as v, convert(DATETIME, '2017-02-06')
.execute()
.then((res: CommandResponse) => {
});
memory leak and Node 7 support
- this release fixes an issue where repeated connection open / close eventually crashes node instance due to memory leak in un-released handles.
- new binaries provided for latest node 7 release.
electron 1.4.3 support + latest node versions
this is a straight rebuild to support latest electron - please inform me of future breaks via an issue and I will try to republish working versions as soon as possible. Note that previous electron version is now removed you must be on 1.4.3 to use this module.
Node v6 latest binaries
this is a patch release containing support for latest v6 Node JS. Both 64 and 32 bit binaries are provided