Comments (7)
you may want to try the latest version on this ... we now channel non crtitcal errors onto a seperate stream, i.e. warnings should not be raised as errors.
from node-sqlserver-v8.
OK, thanks for letting me know, I will take a look and report back shortly.
from node-sqlserver-v8.
I think this related to #34
basically if you use queryRaw you can see how this code should now behave. You can expect a callback with err marked and "more" flag set to true (err, res, more) => { } .
it seems like the query call is not behaving the same way so I will need to change it make them consistent. But this was done to address a problem where the connection could be put in a broken state i.e. the statement not correctly being cleaned up.
I will make a change to query to make it consistent, but the behaviour will no longer be as previous version of the library,
from node-sqlserver-v8.
This also happens for other commands that print out informative messages like BACKUP DATABASE
. Would it be possible to pass severity so a client can decide for itself what to do?
from node-sqlserver-v8.
OK, so far I have a new method on the connection which switches dispatch on and off of these non critical events,
so in following example with flag "true"
class PrintSelect implements SimpleTest {
public run(conn_str:string, argv :any): void {
let delay : number = argv.delay || 5000;
sql.open(conn_str, (err, conn) => {
if (err) {
throw err;
}
let x = 1;
if (err) {
throw err;
}
conn.setFilterNonCriticalErrors(true);
setInterval( () => {
conn.query(`print 'JS status message ${x}'; SELECT ${x} + ${x} as res;SELECT ${x} * ${x} as res2`,
(err, results, more) => {
console.log(`[${x}] more = ${more} err ${err} results ${JSON.stringify(results)}`);
if (more) return;
++x;
})
}, delay);
});
}
}
this will be received as
[1] more = true err null results [{"res":2}]
[1] more = false err null results [{"res2":1}]
[2] more = true err null results [{"res":4}]
[2] more = false err null results [{"res2":4}]
[3] more = true err null results [{"res":6}]
[3] more = false err null results [{"res2":9}]
[4] more = true err null results [{"res":8}]
[4] more = false err null results [{"res2":16}]
with flag false,
[1] more = true err Error: [Microsoft][SQL Server Native Client 11.0][SQL Server]JS status message 1 results null
[1] more = true err null results []
[1] more = true err null results [{"res":2}]
[1] more = false err null results [{"res2":1}]
[2] more = true err Error: [Microsoft][SQL Server Native Client 11.0][SQL Server]JS status message 2 results null
[2] more = true err null results []
[2] more = true err null results [{"res":4}]
[2] more = false err null results [{"res2":4}]
[3] more = true err Error: [Microsoft][SQL Server Native Client 11.0][SQL Server]JS status message 3 results null
[3] more = true err null results []
[3] more = true err null results [{"res":6}]
[3] more = false err null results [{"res2":9}]
I have not yet checked in this change.
from node-sqlserver-v8.
actually thinking a little on this it may be better to use the existing string or object mechanism i.e. where a timeout is set on a query, we can add something along lines of
sql.query(
{
query_timeout : 1, // optional
filter_status_msgs: true // or possibly level i.e. anything < x
}
rather than the rather clumsy method as above.
I will also take a look at how to capture multiple errors from multiple raiseerror .....
from node-sqlserver-v8.
I added a test for this - I think the issue is now resolved and I will close.
test('print raises warning not error', function (testDone) {
var fns = [
function (asyncDone) {
var warnings = []
var err = new Error('[Microsoft][SQL Server Native Client 11.0][SQL Server]print error')
err.code = 0
err.sqlstate = '01000'
var expectedErrors = [err]
var expectedResults = [
{
cnt: 1
}
]
var sql = 'print \'print error\'; select 1 as cnt'
var q = theConnection.query(sql, [], function (err, res, more) {
assert.ifError(err)
if (!more) {
assert(warnings.length === 1)
assert.deepEqual(warnings, expectedErrors)
assert.deepEqual(res, expectedResults)
asyncDone()
}
})
q.on('error', function (err) {
assert.ifError(err)
})
q.on('warning', function (err) {
warnings.push(err)
})
}
]
async.series(fns, function () {
testDone()
})
})
from node-sqlserver-v8.
Related Issues (20)
- Why are database field names garbled when using Chinese fields? HOT 3
- msnodesqlv8 can't find sqltypes.h HOT 2
- install msnodesqlv8 through npm failed HOT 2
- Keep saying Module not found of sqlserverv8 HOT 6
- Question: Using prepared query with Pool
- unable to build on CentOS7 HOT 3
- Prebuilt binaries for Node 20 / alpine HOT 3
- Cannot use without 'require'? HOT 1
- Module not found: Can't resolve '../build/Release/sqlserverv8' HOT 10
- Module did not self-register: sqlserverv8.node HOT 7
- npm install --save msnodesqlv8 fails MSBuild.exe failed with exit code: 1 HOT 5
- import { SqlClient } from "msnodesqlv8/types"; Cannot find module 'msnodesqlv8/types' or its corresponding type declarations HOT 1
- Unable to initialize msnodesql during Hot Module Reload (HMR) HOT 2
- Security vulnerability detected in latest HOT 1
- uncaughtException: Cannot read properties of null (reading 'query') HOT 3
- `ConcreteColumnType.parseSS` method tampers with plain date strings HOT 3
- Cannot find module '../build/Release/sqlserverv8.node' - Windows 10 / node.js v20.11.0/v21.6.1 HOT 1
- npm install results in LNK1127: library is corrupt HOT 1
- Uncaught Exception: static Sybase = new ServerDialect("Sybase")
- Cannot find module 'msnodesqlv8/types' or its corresponding type declarations. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-sqlserver-v8.