Git Product home page Git Product logo

Comments (7)

TimelordUK avatar TimelordUK commented on July 26, 2024 1

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.

TimelordUK avatar TimelordUK commented on July 26, 2024

OK, thanks for letting me know, I will take a look and report back shortly.

from node-sqlserver-v8.

TimelordUK avatar TimelordUK commented on July 26, 2024

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.

ratanaklun avatar ratanaklun commented on July 26, 2024

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.

TimelordUK avatar TimelordUK commented on July 26, 2024

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.

TimelordUK avatar TimelordUK commented on July 26, 2024

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.

TimelordUK avatar TimelordUK commented on July 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.