Git Product home page Git Product logo

Comments (9)

NoelAbrahams avatar NoelAbrahams commented on August 30, 2024

I think this has been the default behaviour inherited from the original node-sqlserver.

How about something like the following:

loadedQuery = `SET NOCOUNT ON ${loadedQuery}`;

from node-sqlserver-v8.

jdpearce avatar jdpearce commented on August 30, 2024

@NoelAbrahams I don't think that would work when loadedQuery is actually a call to a stored procedure.

For now I'm solving this by using the more flag (which doesn't seem to be documented) :

let q = conn.query(loadedQuery, (err, res, more) => {
  results = res;
  if (more === false) {
    console.log(`Final result from query: ${JSON.stringify(results)}`)
  }
});

from node-sqlserver-v8.

NoelAbrahams avatar NoelAbrahams commented on August 30, 2024

Actually it should work for stored procedures:

CREATE PROC dbo.foo 
AS

	DECLARE @v1 table(id int)

	DELETE @v1

	DELETE @v1

GO

SET NOCOUNT OFF 

EXEC dbo.foo

GO

SET NOCOUNT ON 

EXEC dbo.foo	

GO

DROP PROC dbo.foo

from node-sqlserver-v8.

jdpearce avatar jdpearce commented on August 30, 2024

@NoelAbrahams Yes, but not if part of the stored proc sets NOCOUNT OFF...I don't have any control over how the stored procs were set up, so I can't guarantee that isn't the case.

from node-sqlserver-v8.

NoelAbrahams avatar NoelAbrahams commented on August 30, 2024

@jdpearce, I see what you mean - although it is very unusual to set no-count to off. (You could do a find and replace of NOCOUNT in your stored procedure string, but that's probably going into hack territory.)

The reason I suggested the workaround is because the more flag is normally used to process a stored procedure that returns multiple result sets, e.g.

CREATE PROC dbo.foo 
AS

	SELECT v = 'result one'

	SELECT v = 'result two'

from node-sqlserver-v8.

jdpearce avatar jdpearce commented on August 30, 2024

@NoelAbrahams Unfortunately all I have to work with is something that often looks like exec myschema.MyStoredProc @thing = <value>, @thing2 = <value2>...

It's not something I can hack easily, or even tell the library it's a stored proc, because I don't want to get into parsing that string for the params.

So, I can either stick to using the more flag, which works for now and probably won't change, or I can use the "done"/"completed" event incorrectly, i.e. wait for the event and then assume the next result is the last one. That the latter might change seems more likely to me.

from node-sqlserver-v8.

TimelordUK avatar TimelordUK commented on August 30, 2024

an interesting discussion. I guess it boils down to should a change be made to the event ordering, specifically should done actually only fire at the end or should we leave things as they are and add documentation around the more flag explaining how it could be used.

Let me know what you think is the best option given where things stand.

thanks for raising the issue, and for the ensuing discussion.

from node-sqlserver-v8.

jdpearce avatar jdpearce commented on August 30, 2024

You're welcome. ๐Ÿค“

I'd suggest documentation around the "more" flag either way.

If the event ordering is simply inherited from the original project and not an artefact of the underlying protocol, then I'd suggest that the ordering should be changed such that "done" and "completed" both fire after results are received. Documentation should be added to indicate this.

(small aside - what's the difference between "done" and "complete"?)

However, if the event ordering is actually an artefact of the underlying protocol, then simply add documentation about the expected ordering of events.

from node-sqlserver-v8.

TimelordUK avatar TimelordUK commented on August 30, 2024

This issue is resolved in latest version I will hence close. Please let me know if there are anymore problems

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.